Skip to content

Instantly share code, notes, and snippets.

@tdack
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tdack/0b898fbb9ea13198e83f to your computer and use it in GitHub Desktop.
Save tdack/0b898fbb9ea13198e83f to your computer and use it in GitHub Desktop.
Apache MythWeb reverse proxy

Apache reverse proxy configuration for MythWeb over HTTPS

<VirtualHost *:80>
ServerName mythweb-reverse.proxy.com
ServerAdmin foo@bar.com
# redirect http to https
RewriteEngine On
ReWriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName mythweb-reverse.proxy.com
ServerAdmin foo@bar.com
SSLEngine on
SSLCertificateFile /etc/ssl/server/mythweb-reverse.proxy.com.crt
SSLCertificateKeyFile /etc/ssl/private/mythweb-reverse.proxy.com.key
BrowserMatch "MSIE [2-6]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
# MSIE 7 and newer should be able to use keepalive
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
# Rewrite all requests for / to /mythweb
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/$
RewriteRule (.*) /mythweb/ [R=302]
# needed so mod_filter & mod_substitute below work
Header set Accept-Ranges "none"
RequestHeader unset Accept-Encoding
# rewrite http://.... to just //...
FilterDeclare replace
FilterProvider replace SUBSTITUTE "%{CONTENT_TYPE} =~ m|^text/html|"
FilterChain replace
Substitute "s|http://|//|"
<Location /mythweb>
AuthType Digest
AuthName "Mythweb"
AuthDigestDomain /mythweb/
AuthDigestProvider file
AuthUserFile /etc/apache2/passwd/mythweb-reverse.proxy.com.passwd
Require valid-user
</Location>
# Authentication not required for /mythweb/tv/opensearch URLs
<LocationMatch "^/mythweb/tv/opensearch">
Require all granted
</LocationMatch>
ProxyRequests Off
ProxyPass /mythweb http://mythweb.internal.lan/mythweb/
ProxyPassReverse /mythweb http://mythweb.internal.lan/mythweb/
</VirtualHost>
</IfModule>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment