1. Introduction
Having two Raspberry Pi’s running each Webmin /Virtualmin allows to have a test server and an operational server to prevent mistakes stops accessing your websites. As most people will have one external IP address it is required that the first server forwards specific URL’s to the second server. This article describes how redirecting an URL from one Webmin server to another Webmin server needs to be setup.
2. Requirements
For hosting multiple websites on a Raspberry Pi with Virtualmin the following is required before redirecting an URL from one Webmin server to another:
- Two Raspberry Pi servers running Webmin, Virtualmin and Apache server.
- Installed and working Webmin
See article How to install Webmin on a Raspberry Pi? - Installed and working Virtualmin
See article Hosting multiple websites on a Raspberry Pi with Virtualmin - Access to your router to setup port forwarding
- You must have a valid domain name for your Webmin before issuing an SSL certificate using Let’s Encrypt. Make sure the DNS records propagate worldwide, which you can check using an online tool like DNS Checker.
3. Overview of example server setup
In this article we use the following setup as an example. Be aware that your IP adresses and port numbers will be different!
Server 1 (front server, public-facing)
- Apache + Virtualmin
- Serves:
- gallery.fotokruse.eu → normal website
- test.server.com → reverse proxy to Server 2
Server 2 (internal, IP address 192.168.1.44, port 12000)
- Apache + Virtualmin
- Only accessed internally via Server 1
- CSF firewall enabled
- Serves:
- test.server.com
The setup will be such that:
- test.server.com: User goes to https://test.server.com and Apache webserver on Server 1 forwards the request to Server 2 at https://192.168.1.44. The browser URL stays test.server.com.
- gallery.fotokruse.eu: Server 1 handles this request.
Warning!! Replace the yellow highlighted IP addresses and ports with your own.
4. First time setup
This section describes the first time setup for redirecting an URL from one Webmin server to another (from server 1 to server 2) it involves more steps compared with redirecting a site once the first time setup has been done.
If the first time setup has been done you can skip this chapter and use the configuration steps described in chapter 5.
4.1 Configure server 1
Execute the following steps on server 1:
- Enable Required Apache Modules on Server 1 by opening the Terminal and entering the following commands:
1234a2enmod proxya2enmod proxy_httpa2enmod headerssudo systemctl restart apache2
Check correct modules have been installed to allow redirecting an URL from one Webmin server to another:
1apachectl -M | grep -E "proxy|ssl"
The following modules should at least be visible:
– proxy_module
– proxy_http_module
– ssl_module - Create a dedicated virtual host for test.server.com by going to Virtualmin and creating a virtual server. After clicking the Create button the virtual server will be created including SSL certificates.
- Test the site is working by going to https://test.server.com. It should show the default page from Virtualmin for your site originating from Server 1.
- Within Webmin open the filemanager via Tools > File Manager
- Within filemanager click on the folder icon in the upperleft and then go to the folder /etc/apache2/sites enabled
- Right mouse click on test.server.com and select edit
- Remove the line “ProxyPass /.well-known !” or disable the option by putting a # in front. Save and close the editor.
- Go to the existing info for port 443 (starts at something like ‘<VirtualHost *:443>’).
- Add the options below at the end of the 443 block, just before ‘</VirtualHost>’. Save the file and close the editor.
12345678910111213141516# --- Reverse Proxy Settings ---ProxyPreserveHost OnProxyRequests OffSSLProxyEngine On# Ignore backend self-signed cert issues (Webmin default)SSLProxyVerify noneSSLProxyCheckPeerCN offSSLProxyCheckPeerName off# Reverse proxy to internal Webmin serverProxyPass / https://192.168.1.44/ProxyPassReverse / https://192.168.1.44/# Tell backend it is HTTPSRequestHeader set X-Forwarded-Proto "https" - Open the Terminal via Tools > Terminal and restart the Apache webserver:
1sudo systemctl reload apache2
4.2 Configure server 2
4.2.1 Configure Webmin/Virtualmin
Execute the following steps on Server 2:
- Configure the ports and addresses by selecting Webmin → Webmin Configuration → Ports and Addresses and make sure following settings are made:
– Listen on: 192.168.1.44 or 0.0.0.0
– Port: 12000
- Set trusted referers on Server 2 by selecting menu option Webmin → Webmin Configuration → Trusted Referers. Add test.server.com. This will prevent Webmin blocking proxy requests.
4.2.2 Open required ports in the firewall
The instructions below are for the firewall ConfigServer Security & Firewall (CSF):
-
- Allow LAN access (from local network) to Webmin port 12000 by opening the CSF allow file:
1sudo nano /etc/csf/csf.allow
Add the following:
1tcp|in|d=<span style="background-color: #ffff00;">12000</span>|s=<span style="background-color: #ffff00;">192.168.1</span>.0/24
Save the file and close the editor. - Add port 12000 to CSF allowed TCP_IN by opening the CSF config file:
1sudo nano /etc/csf/csf.conf
Find the line which looks like:
1TCP_IN = "22,80,443"
And add the port 12000. Save the file and close the editor. - Reload CSF:
1sudo csf -r - Test the port is open:
1sudo csf -g <span style="background-color: #ffff00;">192.168.1.44</span>
- Allow LAN access (from local network) to Webmin port 12000 by opening the CSF allow file:
5. Setup next website(s)
Once the first time setup has been done the steps for redirecting an URL from one Webmin server to another (from server 1 to server 2) becomes easier. The site used as an example now is https://testnew.server.com.
5.1 Configure server 1
Execute the following steps on server 1:
- Create a dedicated virtual host for testnew.server.com by going to Virtualmin and creating a virtual server. After clicking the Create button the virtual server will be created including SSL certificates.NOTE: If you have restored a Virtualmin backup (for example see Restoring a Piwigo backup at a Webmin server) then this step can be skipped as the restore will take care of this.
- Test the site is working by going to https://testnew.server.com. It should show the default page from Virtualmin for your site.
- Within Webmin open the filemanager via Tools > File Manager
- Within filemanager click on the folder icon in the upperleft and then go to the folder /etc/apache2/sites enabled
- Right mouse click on testnew.server.com and select edit
- Modify the existing info for port 443 (starts at something like ‘<VirtualHost *:443>’).
a. Add the options below at the end of the 443 block, just before ‘</VirtualHost>’.
12345678910111213141516# --- Reverse Proxy Settings ---ProxyPreserveHost OnProxyRequests OffSSLProxyEngine On# Ignore backend self-signed cert issues (Webmin default)SSLProxyVerify noneSSLProxyCheckPeerCN offSSLProxyCheckPeerName off# Reverse proxy to internal Webmin server 2ProxyPass / https://192.168.1.44/ProxyPassReverse / https://192.168.1.44/# Tell backend it is HTTPSRequestHeader set X-Forwarded-Proto "https" - Remove the line “ProxyPass /.well-known !” or disable the option by putting a # in front.
- Save and close the editor.
- Open the Terminal via Tools > Terminal and restart the Apache webserver:
1sudo systemctl reload apache2
5.2 Configure server 2
Now Server 1 has been configured for redirecting an URL from one Webmin server to another it is time to configure Webmin/Virtualmin on Server 2 by executing the following steps:
- Set trusted referers by selecting menu option Webmin → Webmin Configuration → Trusted Referers.
- Add testnew.server.com.This will prevent Webmin blocking proxy requests.
- Create the virtual server testnew.server.com at Server 2. Enabled features can be modified as needed. In the example only Apache website is selected.NOTE: If you have restored a Virtualmin backup (for example see Restoring a Piwigo backup at a Webmin server) then this step can be skipped as the restore will take care of this.
5.3. Testing
- Open https://testnew.server.com. It should show the site from Server 2, URL stays the same.
- Open https://gallery.fotokruse.eu. Check that this website running on Server 1 works.
This concludes the setup of redirecting an URL from one Webmin server to another Webmin server.
7. Common issues
Some issues which might occur redirecting an URL from one Webmin server to another:
- Piwigo website does not work and gives error message; see Restoring a Piwigo backup at a Webmin server, likely it has to do with server quota set.
- LProxyEngine Off → HTTPS proxy fails
- Webmin redirecting to its own hostname/IP → add Trusted Referers and disable forced redirects
- CSF blocks port(s) → check with csf -g






0 Comments