Using Joomla on Apache behind Apache Reverse Proxy - apache

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.

Related

Forwarding subdomain to a port of localhost using WHM and apache2

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>

apache2 virtual host proxy subdomain to another port on the same machine

I have php service running on mydomain.com, and I have node application running on mydomain.com:8000, now I try to map sub.mydomain.com to mydomain.com:8000 using apache's virtual host.
I've setup blog.mydomain.com to resolve to mydomain.com in DNS
but the problem is no matter how I try to write the config file, things went wrong
<VirtualHost sub.mydomain.com:80>
ServerName blog.gespiton.cn
ProxyRequests On
<Location />
ProxyPreserveHost On
ProxyPass http://localhost:3000/
ProxyPassReverse http://localhost:3000/
</Location>
</VirtualHost>
when I write sub.mydomain.com as virturalhost, it has none effect. but if I change it to *:80, all the urls are routed to mydomain.com:8000
how can I only route sub.mydomain.com to 8000 port and mydomain.com in port 80

Two applications on same port 80 with apache proxy?

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>

apache redirection to niginx based on domain name

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>

Subdomain under Apache to proxy into Tomcat

I'm having trouble with making a subdomain to my Windows computer while using AJP to proxy to Tomcat. This is what I have in my httpd.conf file:
<VirtualHost *:80>
ServerName subdomain.localhost
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / ajp://localhost:8009/folder/
ProxyPassReverse / ajp://localhost:8009/folder/
<Location />
Order allow,deny
Allow from all
</Location>
</VirtualHost>
The subdomain has been added to `c:\windows\system32\drivers\etc\hosts
127.0.0.1 localhost
127.0.0.1 subdomain.localhost
When I go to http://localhost i goes straight to the proxy. When I go to http://subdomain.localhost i goes to the proxy as well. How do I make is so the subdomain only goes to the proxy and the regular goes to Apache?
You need to declare a second VirtualHost with localhost as the ServerName.
This should probably be moved to superuser.com but one thing to try:
<VirtualHost *:80> informs it to accept all incoming connections on port 80 to use these settings. I would try changing it to say:
<VirtualHost subdomain.localhost:80>
and see if that only applies these settings when the subdomain is used.
The ServerName tag that you put with the subdomain doesn't tell it who to listen for. The official documentation states:
The ServerName directive sets the
hostname and port that the server uses
to identify itself. This is used when
creating redirection URLs. For
example, if the name of the machine
hosting the web server is
simple.example.com, but the machine
also has the DNS alias www.example.com
and you wish the web server to be so
identified, the following directive
should be used:
You can read more on these configurations here.