I have two applications on one server: Redmine running under Apache and application running under WildFly. Now, Redmine runs on port 80 and the other application runs on port 8080.
Is it possible to run them both on port 80 using Apache reverse proxy ? This server would have assigned two domain names: app.domain.com for application under WildFly and redmine.domain.com for redmine application under Apache.
Is it possible to achieve following behavior ?
I access to redmine.domain.com, I am redirected to /var/www/redmine DocumentRoot folder.
And when I access to client.domain.com, I am redirected to http://localhost:8080.
Thank you
This is easy to do with apache. You can't bind two applications to one port but you can have apache route them.
What you want to do is run Apache on port 80, wildfly on 8080, redmine on 8081.
Within apache the configuration would look like this:
<VirtualHost app.domain.com:80>
ProxyPass / http://127.0.0.1:8080/ retry=0
ProxyPassReverse / http://127.0.0.1:8080/
</VirtualHost>
<VirtualHost redmine.domain.com:80>
ProxyPass / http://127.0.0.1:8081/ retry=0
ProxyPassReverse / http://127.0.0.1:8081/
</VirtualHost>
Related
In brief, I can access my site using example.com:3000 but I want to access it using sub.example.com.
I am using WHM to manage my server using the example.com domain. I have added a DNS Zone using the WHM control panel for sub.example.com. It works fine and redirects to sub.example.com/cgi-sys/defaultwebpage.cgi.
I also tried to make a reverse proxy using VirtualHost by adding the following lines to the /etc/apache2/conf/httpd.conf file as mentioned in here:
<VirtualHost *:80>
ServerName sub.example.com
ProxyPreserveHost on
ProxyPass / http://localhost:3000/
</VirtualHost>
Then I restarted the Apache server using sudo systemctl restart httpd. However the subdomain still redirects to the sub.example.com/cgi-sys/defaultwebpage.cgi path rather than forwarding to the port:3000. Could you please help me resolve this problem?
It is worth mentioning that the server is using WHM and CPanel (version 84.0.21) on CentOS (version 7.7) as well as Apache (version 2.4.41) and the port:3000 is connected to a docker image (gitea) via docker-compose.
I had the same issue with the same setup and was able to solve it by using this configuration:
<VirtualHost sub.example.com:80>
ServerName sub.example.com
ServerAlias sub.example.com
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
</VirtualHost>
Adding it to Apache's include directive in WHM:
https://docs.cpanel.net/whm/service-configuration/include-editor/
For SSL port 443 you have to use the IP instead of domain:
<VirtualHost 1.1.1.1:443>
I have two docker containers running Tornado applications, named app1 and app2 on a Ubuntu VM. The VM has a domain name ubuntu.somesite.com. I can access one of them with docker port forwarding at ubuntu.somesite.com:8080. Instead I want both apps to be accessible at ubuntu.somesite.com/app1 and ubuntu.somesite.com/app2. What would be the best way to accomplish this? I tried using apache virtual hosts but didn't get very far.
You need to expose both docker containers on the host network, of course on two different ports (let's say 8080 and 8081).
Than you need a reverse proxy in your host. Apache 2.4 is one possible choice.
You could use a virtualhost like this:
<VirtualHost *:80>
ServerName ubuntu.somesite.com
<Location />
Order allow,deny
Allow from all
Require all granted
</Location>
ProxyPass /app1 http://127.0.0.1:8080/
ProxyPassReverse /app1 http://127.0.0.1:8080/
ProxyPass /app2/ http://127.0.0.1:8081/
ProxyPassReverse /app2/ http://127.0.0.1:8081/
</VirtualHost>
Please note that this config will not work with apache 2.2 or older.
I have a Joomla Installation on Apache2 (Port 83) running on Ubuntu 16.04 Server.
When I connect to the page from the local network like 192.168.178.14:83 it appears and everything is fine. To access my page from the Internet there is another Server running Apache2, that acts as a Proxy Server. All traffic going trough Port 80 and 443 come to this machine, using the ServerName it decide to which machine the traffic have to be forwarded. That's working fine for about 10 domains and machines.
But when I connect to my Joomla Domain I get a HTML Site without any formatting, graphics and templates. When I forward a Port directly to this machine everything works fine again, using this port to connect.
network topologie
My VirtualHost config on Ubuntu1:
<VirtualHost *:80>
ServerName ksg-events.de
Redirect permanent / https://ksg-events.de/
</VirtualHost>
<VirtualHost *:443>
ServerName ksg-events.de
ProxyPreserveHost On
ProxyRequests Off
ProxyVia Off
ProxyPass / http://192.168.178.14:83/
ProxyPassReverse / http://192.168.178.14:83/
SSLCertificateFile /etc/letsencrypt/live/ksg-events.de/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/ksg-events.de/privkey.pem
</VirtualHost>
Virtual Host config on Ubuntu2:
<VirtualHost *:83>
DocumentRoot /var/www/ksg-events.de/joomla
</VirtualHost>
Thanks for your help!
I find a solution to my problem:
Run Joomla behind Apache reverse proxy (http):
Add ProxyVia full to proxy's VirtualHost config
Using https:
Enable mod_headers on proxy server
Add RequestHeader set X-Forwarded-Proto "https" to proxy's VirtualHost
I hope that can help someone who run into the same problems.
I am using Apache Tomcat for deploying the application.The application require ProxyPass and ProxyPassReverse to be configured,I have read documents stating that the ProxyPass are served by Apache Server.How can I serve and configure the same using tomcat without using Apache Server.
I have read the below codeis configured in httpd.conf file of Apache server for serving proxyPass and ProxyPassreverse:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName 127.0.0.1
DocumentRoot /var/www
ProxyRequests Off
ProxyPreserveHost On
ProxyPass /static/ !
ProxyPass / ajp://localhost:8009/
ProxyPassReverse / ajp://localhost:8009/
.
.
.
Alias /static/ "/apache/www/"
</VirtualHost>
These directives are used if you have a reverse proxy "in front" of tomcat. In this case, if the reverse proxy is Apache httpd. The directives are required because tomcat might not know the original request's target, and httpd can "translate" from what tomcat thinks the request should look like to what the user's browser needs the request to be.
If you do not have a reverse proxy in the game, Tomcat would see the original request data, and all of these instructions can simply be omitted.
If you are using a different reverse proxy (say nginx) you'll need to find the equivalent instructions that make the reverse proxy of your choice adapt both worlds to each other.
Another message of caution: If you're handling everything on Tomcat, make sure you're not running as root just in order to bind to ports 80 or 443. You must not run tomcat as root! (If you don't: Good. I've put it here for everybody who reads it. Can't be repeated often enough)
I have got APP1 running on apache httd over port 80, which will be reached via app1.abc.com , and I have got another app running on nginx over 8080 port on the same server which can be reached via app2.abc.com:8080.
Infact both app1.abc.com and app2.abc.com mapped to same IP x.x.x.1. So now I would like to know if I can configure some redirect rule in apache like, when traffic comes from app2.abc.com, with out 8080 port specified I should be internally routing this to nginx over 8080 port based on the domain that I came from.
Any help on this would be greatly helpful.
Update 1
I have tried this apache reverse proxy config.
ServerName app1.subdomain.domain.com
ServerAlias app1-app
ProxyPass / http://0.0.0.0:80/
ProxyPassReverse / http://0.0.0.0:80/
</VirtualHost>
<VirtualHost *:80>
ServerName app11.app1.subdomain.domain.com
ServerAlias vpstage-target
ProxyPass / http://0.0.0.0:8080/
ProxyPassReverse / http://0.0.0.0:8080/
</VirtualHost>