Introduction
In today's digital world, having a dynamic IP address can be a challenge when trying to set up a reverse proxy server using Apache. This article will walk you through the process of creating a reverse proxy with Apache that allows SWAN (Secure Web Accelerator) connections on various servers with a local LAN-based DynDNS name.
Prerequisites
Before we begin, ensure that:
- You have a dynamic IP address and have set up a DynDNS name.
- You have access to the Apache web server configuration files.
- You have installed and configured the mod_proxy and mod_ssl modules.
Configuring Apache Reverse Proxy
To configure Apache as a reverse proxy server, follow these steps:
Create a New Virtual Host Configuration File
Create a new virtual host configuration file for your DynDNS name. For example:
sudo nano /etc/apache2/sites-available/reverse-proxy.conf
Configure the Virtual Host
Edit the new virtual host configuration file and add the following content:
ServerName mysite.dyndns.org
ServerAdmin [email protected]
ProxyPreserveHost On
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
ProxyPassReverseCookieDomain mysite.dyndns.org
ProxyPassReverseCookiePath /
SSLEngine On
SSLCertificateFile /path/to/your/cert.pem
SSLCertificateKeyFile /path/to/your/key.pem
Enable the Virtual Host
Enable the new virtual host configuration by creating a symbolic link to the sites-enabled directory:
sudo ln -s /etc/apache2/sites-available/reverse-proxy.conf /etc/apache2/sites-enabled/
Configuring the SWAN Server
Configure the SWAN server to use the reverse proxy:
# /etc/swan.d/10-nat.conf
nat_traversal {
extern server apache_server localhost 80;
}
/etc/swan.d/10-proxy.conf
forward-port tcp:8080 local:8080
/etc/swan.d/20-nat.conf
nat_traversal {
extern server apache_server mysite.dyndns.org:80;
}
Testing the Setup
Test the reverse proxy setup by accessing your DynDNS name:
http://mysite.dyndns.org