I am trying to use Apache to serve multiple sites at the same time, the structure I want to obtain is composed by a main site at example.com
and use the subdomains radarr.example.com
and sonarr.example.com
to access my Radarr and Sonarr servers.
The main site is hosted on machine1, I set up a virtual host using apache and certbot:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName example.com
WSGIDaemonProcess sflasksite user=www-data group=www-data threads=5
WSGIScriptAlias / /var/www/webapp/app.wsgi
<Directory /var/www/webapp>
WSGIProcessGroup sflasksite
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Require all granted
</Directory>
Alias /static /var/www/webapp/static
<Directory /var/www/webapp/static/>
Order deny,allow
Require all granted
</Directory>
ErrorLog /var/www/webapp/logs/error.log
CustomLog /var/www/webapp/logs/access.log combined
SSLCertificateFile /etc/letsencrypt/live/example.com-0002/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com-0002/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
The two servers I want to serve are on machine2, on the same network as machine1, how can I obtain the two services respectively on radarr.example.com
and sonarr.example.com
?
After some reading, I tried to use a Reverse Proxy, configuring a virtual host for each service as follows:
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerAlias radarr.example.com
ProxyPass / http://192.168.1.20:7878/
ProxyPassReverse / http://192.168.1.20:7878/
ErrorLog /var/www/radarr/logs/error.log
CustomLog /var/www/radarr/logs/access.log combined
</VirtualHost>
and alike for Sonarr.
However, when I navigate to radarr.example.com
, I do not get the expected service but the main site.
How can I get the reverse proxy to work? Or should I switch to another strategy altogether?
EDIT:
I am also open to abandon apache if someone knows and can suggest a simpler way of doing this.