Skip to content

Instantly share code, notes, and snippets.

@mschmitt
Created July 29, 2013 13:50
Show Gist options
  • Save mschmitt/6104429 to your computer and use it in GitHub Desktop.
Save mschmitt/6104429 to your computer and use it in GitHub Desktop.
Apache mod_rewrite reverse proxy with SSL bound to two ports, proxying to two separate backends
<VirtualHost _default_:443 _default_:8443>
# Force %{SERVER_PORT} to contain the actual local port of the connection
UseCanonicalPhysicalPort On
RewriteEngine On
# Reverse Proxy to localhost:80 if connection was to port 443
RewriteCond %{SERVER_PORT} =443
RewriteRule (.*) http://localhost$1 [P]
# Reverse Proxy to localhost:8080 if connection was to port 8443
RewriteCond %{SERVER_PORT} =8443
RewriteRule (.*) http://localhost:8080$1 [P]
SSLEngine On
SSLCertificateFile /etc/httpd/ssl/foo.crt
SSLCertificateKeyFile /etc/httpd/ssl/foo.key
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment