I am trying to set up Apache as a reverse proxy on a new Ubuntu 22.04 virtual machine. We have an existing Apache reverse proxy on Ubuntu 18.04 where everything is working as intended. This new reverse proxy is supposed to replace our older one, but the virtual hosts don't seem to be working correctly.
I have done the following:
apt-get update
apt-get upgrade
apt-get install apache2
a2enmod proxy
a2enmod proxy_http
a2enmod proxy_balancer
a2enmod lbmethod_byrequests
I disabled the default page in sites-enabled.
a2dissite 000-default.conf
I then created a new virtual host and enabled it.
vi 001-trupage.azmedien.ch.conf
a2ensite 001-trupage.azmedien.ch.conf
It looks like this:
<VirtualHost trupage.azmedien.ch:80>
ServerName trupage.azmedien.ch
ProxyPreserveHost On
ProxyPass / http://10.200.0.130/
ProxyPassReverse / http://10.200.0.130/
</VirtualHost>
I then restarted & reloaded the Apache.
systemctl restart apache2
systemctl reload apache2
I created a host file entry on my Windows PC to test if this very basic configuration works, it points to my Apache server.
When I then try to reach trupage.azmedien.ch it leads me to the Apache default website instead of actually redirecting me to the correct server (which is defined with ProxyPass in the virtual host).
It seems like it doesn't recognize the virtualhost for some reason? When I replace "trupage.azmedien.ch:80" with "*:80" and then open it in my browser the ProxyPass works. But obviously, that is not what I want as there will be multiple virtual hosts.
<VirtualHost *:80>
ServerName trupage.azmedien.ch
ProxyPreserveHost On
ProxyPass / http://10.200.0.130/
ProxyPassReverse / http://10.200.0.130/
</VirtualHost>
Here is the output from apache2ctl -S
, 213.146.11.131 is the IP of the old reverse proxy, but I have no clue where it's coming from or why it's showing up here:
root@azprox10:~# apache2ctl -S
AH00558: apache2: Could not reliably determine the server's fully qualified doma in name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress th is message
VirtualHost configuration:
213.146.11.131:80 is a NameVirtualHost
default server localhost (/etc/apache2/sites-enabled/001-trupage.azmedi
en.ch.conf:1)
port 80 namevhost localhost (/etc/apache2/sites-enabled/001-trupage.azm
edien.ch.conf:1)
port 80 namevhost opvsg.chmedia.ch (/etc/apache2/sites-enabled/002-opvs
g.chmedia.ch.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex rewrite-map: using_defaults
Mutex proxy: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex watchdog-callback: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33