Host 2 application under one domain Apache HTTPD - ruby

I'm trying to configure Apache HTTPD 2.4 to front two different applications being hosted on the same server.
App1 is reachable on port 8080 (Tomcat)
mysingledomain.com:8080
App2 is reachable on port 3030 (Ruby [Dashing])
mysingledomain.com:3030
What I want to do is reach them respectively as mysingledomain.com/App1 and mysingledomain.com/App2
My situation is a lot like how this question start:
Host 2 Sites in HTTPD
These are both SPA applications but I'm getting quite confused on how to set this up when I do not have a DocumentRoot to separate the configuration.
How would I setup HTTPD to front the HTTP requests in this manner?
I was able to configure the ruby application to adhere to a subpath with the following configuration, but this affects the other:
<VirtualHost *:80>
ProxyRequests On # <---- WARNING DO NOT DO THIS
ProxyVia On
ProxyPreserveHost On
RewriteEngine On
ProxyPass "/app2" "http://192.168.0.62:3030/" retry=0
ProxyPassReverse "/app2/" "http://192.168.0.62/"
RewriteRule "^/assets/(.*)" "/app2/assets/$1" [R]
RewriteRule "^/views/(.*)" "/app2/views/$1" [R]
</VirtualHost>

It should be as simple as this:
<VirtualHost *:80>
ServerName mysingledomain.com
ProxyPreserveHost On
ProxyPass /App1/ http://127.0.0.1:8080/
ProxyPassReverse /App1/ http://127.0.0.1:8080/
ProxyPass /App2/ http://127.0.0.1:3030/
ProxyPassReverse /App2/ http://127.0.0.1:3030/
</VirtualHost>

Related

why show me ':8000' in my vircualhost in laragon?

in host file :
#
127.0.0.1 localhost
::1 localhost
127.0.0.1 daily_tasks.local #laragon magic!
D:\laragon\etc\apache2\sites-enabled\auto.daily_tasks.local.conf :
<VirtualHost *:80>
DocumentRoot "D:/laragon/www/daily_tasks/public"
ServerName daily_tasks.local
ServerAlias *.daily_tasks.local
<Directory "D:/laragon/www/daily_tasks/public">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
# If you want to use SSL, enable it by going to Menu > Apache > SSL > Enabled
but whene run php artisan serv for run laravel. in browser this url http://daily_tasks.local:8000/ is working!
I don't want it to be displayed :8000 !
Laragon provides friendly url when the server is up. Only put your folder into www folder and restart Apache in Laragon, it'll detect a new project and that is all. You won't need php artisan serve.
DOCS: https://laragon.org/docs/pretty-urls.html
how about proxy pass?
<VirtualHost *:80>
...
ProxyPreserveHost On
ProxyRequests Off
ProxyPass / http://localhost:8000/
ProxyPassReverse / http://localhost:8000/
...
</VirtualHost>

Oracle Apex pretty URL

i need help for a problem.
Before someone complain. I have post the same question in another forum but i didn't get any useful help there.
https://community.oracle.com/tech/developers/discussion/4497783
I have seen there are a lot of things if i search by google but i am a total newbie so i hope that someone could help me.
I have a dedicated Server with apex running. I have point a domain to my apex application, so far , so good.
Now i have the url like following www.mydomain.com/apex/workspace_name/r/application
What i want to do is, that the user don't see the part "/apex/workspace_name/r" when he is working with the application.
Is there a relative easy way to do that? Something like .htaccess?
Many thanks and regards,
Andreas
Using an Apache HTTPD web server to reverse proxy your APEX connections, you can use the ProxyPass and ProxyPassReverse directives of the mod_proxy module to alter URL paths that the user sees:
ProxyPass /r /apex/workspace_name/r
ProxyPassReverse /r /apex/workspace_name/r
See the Apache documentation for more details: https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxypass
In my case, I used the mod_proxy_ajp module to communicate with the cluster of Tomcat application servers running ORDS, as follows:
#######################################################
#
# APEX Virtual Host
#
#######################################################
<VirtualHost 192.168.1.101:443>
# General setup for the virtual host
DocumentRoot "/var/www/html"
ServerName apps.mydomain.com
ServerAdmin root#localhost
ErrorLog "/etc/httpd/logs/apex.ssl_error.log"
# Redirect root URL to a default application
RedirectMatch ^/$ /ords/f?p=200
... other directives here ...
<IfModule mod_proxy_ajp.c>
ProxyRequests Off
ProxyPreserveHost On
<Proxy balancer://ords_balancer>
BalancerMember ajp://appserver1:8009 route=server1
BalancerMember ajp://appserver2:8009 route=server2
</Proxy>
# Redirect /ords to the load balancer
ProxyPass /ords balancer://ords_balancer/ords stickysession=JSESSIONID|jsessionid
ProxyPassReverse /ords balancer://ords_balancer/ords
ProxyPassReverseCookiePath /ords /
# Redirect /i to the load balancer
ProxyPass /i balancer://ords_balancer/i stickysession=JSESSIONID|jsessionid
ProxyPassReverse /i balancer://ords_balancer/i
<Proxy *>
Order deny,allow
Deny from none
Allow from localhost
</Proxy>
<Location /balancer-manager>
SetHandler balancer-manager
</Location>
</IfModule>
</VirtualHost>

Laravel Websockets Apache2 ReverseProxy setup

Problem
I am trying to setup a live environment with laravel websockets library behind an apache server.
The Websocket server is running on port 6001 (unreachable from outside).
The Apache VHost is configured for ws.example.com
I cannot get the Apache to proxy the wss:// requests correctly.
The request to wss://ws.example.com/request/path?protocol=7&client=js&version=5.1.1&flash=false fails.
(Error during WebSocket handshake: Invalid status line)
I think there is a problem with my vhost configuration. Am I missing something? Any advice is appreciated.
vhost configuration
<VirtualHost *:443>
ServerName ws.example.com
ServerAlias www.ws.example.com.com
DocumentRoot /srv/vhost/example.com/domains/ws.example.com/public_html
ErrorLog /var/log/virtualmin/ws.example.com_error_log
CustomLog /var/log/virtualmin/ws.example.com_access_log combined
ScriptAlias /cgi-bin/ /srv/vhost/example.com/domains/ws.example.com/cgi-bin/
DirectoryIndex index.php index.html
RewriteEngine on
ProxyRequests off
ProxyVia on
RewriteCond %{HTTP:Connection} Upgrade [NC]
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteRule /(.*) ws://localhost:6001/$1 [P,L]
ProxyPass /request/path http://localhost:6001/request/path
ProxyPassReverse /request/path http://localhost:6001/request/path
SSLCertificateFile /etc/letsencrypt/path/ws.example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/path/ws.example.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
Create a subdomain for websockets. Then edit your virtualhost configs (Apache 2.4) as below. Use pusher-php-server 5.0.3
<VirtualHost *:443>
ServerAdmin admin#example.com
ServerName socket.website.com
<Proxy *>
Require all granted
Allow from all
</Proxy>
SSLEngine on
SSLProxyEngine on
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off
RewriteEngine on
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule .* wss://127.0.0.1:6001%{REQUEST_URI} [P]
ProxyPass / ws://127.0.0.1:6001
ProxyPassReverse / ws://127.0.0.1:6001
SSLCertificateFile /etc/letsencrypt/live/socket.website.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/socket.website.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
#max: your rewrite rules were the key, also applies when the proxy just forwards the unencrypted traffic and apache is handling ssl to the outside, replacing wss with ws then - after one day of fiddling its finally working!
edit: not enough reputation for a comment , sorry

(Apache) Redirect https domain to port serve throw https

I have done redirection in apache before but in a simple way what I do is that enable rewrite module in apache server and then add the two .conf file in /etc/apache2/sites-available mentioned below
The below file is for redirecting HTTP request received throw domain to a specific port.
<VirtualHost *:80>
ServerAdmin me#mydomain.com
ServerName test.domain.com
ProxyPreserveHost On
# setup the proxy
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPass / https://localhost:3235/
ProxyPassReverse / https://localhost:3235/
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteCond %{SERVER_NAME} =chat-dev.motivone.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
The below file is for redirecting HTTPS request received throw domain to a specific port.
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin me#mydomain.com
ServerName test.domain.com
ProxyPreserveHost On
# setup the proxy
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPass / https://localhost:3235/
ProxyPassReverse / https://localhost:3235/
SSLCertificateFile /etc/letsencrypt/live/test.domain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/test.domain.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
this process just works fine when I run my server throws HTTP and change proxy to HTTP but when I run my server on https and then try to redirect it. its throw the error like
i am not sure what is wrong ay kind of help is appriciable thanks in advance

Adding a 8080 to each URl using URl rewriting?

I have a domain like www.mytest.com. Now for each subpage of that page and the domain itself I want to add :8080. Like this:
www.mytest.com/correct.php --> www.mytest.com:8080/correct.php
How can I do that?
Thanks!
You can use proxy pass reverse assuming that you activate (listen on) port 8080 in your httpd.conf file or VirtualHost file assuming you're using Apache HTTPD and have root access. If not, believe you can put this into .htaccess:
<VirtualHost *:80>
...
<Proxy *>
AddDefaultCharset Off
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://www.mytest.com:8080
ProxyPassReverse / http://www.mytest.com:8080
</VirtualHost>

Resources