Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save grrowl/010d2892c7b16f2a0e5e40f83e671ca7 to your computer and use it in GitHub Desktop.
Save grrowl/010d2892c7b16f2a0e5e40f83e671ca7 to your computer and use it in GitHub Desktop.
Apache2 reverse proxy vhost configuration for Plex. Rerquires modules ssl, proxy, wstunnel
ServerSignature Off
ServerTokens Prod
<VirtualHost *:80>
ServerName plex.website.com
# This VirtualHost redirects everything to HTTPS on port 443.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>
<VirtualHost *:443>
ServerName plex.website.com
ServerAlias ""
Options -Includes -ExecCGI
RewriteEngine On
RewriteCond %{THE_REQUEST} !HTTP/1.1$
RewriteRule .* - [F]
LimitRequestBody 512000
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/cert.pem
SSLCertificateKeyFile /etc/apache2/ssl/privkey.pem
SSLProtocol +TLSv1.2
Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains; preload"
Header always set X-Frame-Options DENY
FileETag None
TraceEnable off
#Header edit Set-Cookie ^(.*)$ ;HttpOnly;Secure
Header set X-XSS-Protection "1; mode=block"
Timeout 60
<Location /:/websockets/notifications>
ProxyPass wss://plex:32400/:/websockets/notifications #plex here is resolved to my plex container
ProxyPassReverse wss://plex:32400/:/websockets/notifications #plex here is resolved to my plex container
</Location>
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyRequests Off
ProxyPreserveHost On
SSLProxyEngine On
RequestHeader set Front-End-Https "On"
ProxyPass / http://plex:32400/ #plex here is resolved to my plex container
ProxyPassReverse / http://plex:32400/ #plex here is resolved to my plex container
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/web
RewriteCond %{HTTP:X-Plex-Device} ^$
RewriteCond %{REQUEST_METHOD} !^(OPTIONS)$
RewriteRule ^/$ /web/$1 [R,L]
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment