Placing SwiperProxy behind an apache2 reverse proxy
You will need to either run SwiperProxy as its own virtual host at the web root, due to how URL rewriting works - or use endpoints in proxy.conf
Required modules
- mod_proxy
- mod_proxy_http
- mod_rewrite
- mod_ssl
Example apache2 configuration
<VirtualHost *:80>
# Define our hostname, and with wildcard prefix for oldstyle DNS
# rewriting.
ServerName proxy.example.org
ServerAlias *.proxy.example.org
# Who to display as contact in case of errors.
ServerAdmin hostmaster@example.org
# Logging.
ErrorLog ${APACHE_LOG_DIR}/proxy.example.org.error.log
# Proxy to the Proxy.py HTTP listener port.
ProxyPass / http://127.0.0.1:8080/ \
connectiontimeout=1 timeout=10 disablereuse=on retry=1
ProxyPassReverse / http://127.0.0.1:8080/
# Rewrite old-style DNS rewrites to the new suffixed method.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.+)\.proxy\.example\.org$
RewriteRule ^/(.*)$ http://proxy.example.org/%1/$1 [L]
</VirtualHost>
<VirtualHost *:443>
# Define our hostname, and with wildcard prefix for old-style DNS
# rewriting.
ServerName proxy.example.org
ServerAlias *.proxy.example.org
# Who to display as contact in case of errors.
ServerAdmin hostmaster@example.org
# Logging.
ErrorLog ${APACHE_LOG_DIR}/proxy.example.org.error.log
# Initialize the TLS engine.
SSLEngine on
# Define the x.509 certificates.
SSLCertificateFile /etc/ssl/certs/proxy.example.org.pem
SSLCertificateKeyFile /etc/ssl/private/proxy.example.org.key
SSLVerifyClient none
# Set some TLS environment variables.
SetEnv force-proxy-request-1.0 1
SetEnv proxy-nokeepalive 1
# Proxy to the Proxy.py HTTPS listener port.
SSLProxyEngine on
ProxyPreserveHost on
ProxyPass / https://127.0.0.1:40443/ \
connectiontimeout=3 timeout=10 disablereuse=on retry=1
ProxyPassReverse / https://127.0.0.1:40443
# Rewrite old-style DNS rewrites to the new suffixed method.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.+)\.proxy\.example\.org$
RewriteRule ^/(.*)$ https://proxy.example.org/%1/$1 [L]
</VirtualHost>