-
-
Save shadycuz/fbee5a6163f2f9f86576e223ae2db250 to your computer and use it in GitHub Desktop.
Nginx Reverse Proxy config for Plex to prevent user from needing port or /web/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream plex-upstream { | |
# change plex-server.example.com:32400 to the hostname:port of your plex server. | |
# this can be "localhost:32400", for instance, if Plex is running on the same server as nginx. | |
# I just use the IP and port of my server | |
server plex-server.example.com:32400; | |
} | |
server { | |
listen 80; | |
# server names for this server. | |
# any requests that come in that match any these names will use the proxy. | |
# You can use one or many names. I just use plex.mydomain.com | |
server_name | |
# tv | |
# plex | |
# tv.example.com | |
plex.example.com; | |
# this is where everything cool happens (you probably don't need to change anything here): | |
location / { | |
# if a request to / comes in, 301 redirect to the main plex page. | |
# but only if it doesn't contain the X-Plex-Device-Name header | |
# this fixes a bug where you get permission issues when accessing the web dashboard | |
# Mine works with out this but I will leave it it here. | |
if ($http_x_plex_device_name = '') { | |
rewrite ^/$ http://$http_host/web/index.html; | |
} | |
# set some headers and proxy stuff. | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_redirect off; | |
# Extra headers by Doogna | |
# Might not be needed but I use them | |
proxy_set_header X-Plex-Device $http_x_plex_device; | |
proxy_set_header X-Plex-Device-Name $http_x_plex_device_name; | |
proxy_set_header X-Plex-Platform $http_x_plex_platform; | |
proxy_set_header X-Plex-Platform-Version $http_x_plex_platform_version; | |
proxy_set_header X-Plex-Product $http_x_plex_product; | |
proxy_set_header X-Plex-Token $http_x_plex_token; | |
proxy_set_header X-Plex-Version $http_x_plex_version; | |
proxy_set_header X-Plex-Nocache $http_x_plex_nocache; | |
proxy_set_header X-Plex-Provides $http_x_plex_provides; | |
proxy_set_header X-Plex-Device-Vendor $http_x_plex_device_vendor; | |
proxy_set_header X-Plex-Model $http_x_plex_model; | |
# include Host header | |
proxy_set_header Host $http_host; | |
# proxy request to plex server | |
#I had to change this | |
#proxy_pass http://plex-upstream; | |
#to this to get it work | |
proxy_pass http://plex-upstream/; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment