Skip to content

Instantly share code, notes, and snippets.

@ahmedsajid
Last active March 14, 2019 01:02
Show Gist options
  • Save ahmedsajid/8b5751b542b657ba8dade6b2e3aabc6d to your computer and use it in GitHub Desktop.
Save ahmedsajid/8b5751b542b657ba8dade6b2e3aabc6d to your computer and use it in GitHub Desktop.
Nginx Plex Config

Nginx config for Plex

Currently if Plex server is exposed on the internet and someone tries to access it, Plex forces you to login using plex id.

This nginx config tricks plex into thinking that request is coming from LAN.

# Control access to plex based on IPs
# This allows login to plex to remote hosts without login
#
# Change 192.168.0.50 to your Plex IP in proxy_pass
#
# Accessing plex remotely: http://remoteip:32400/web/index.html
# and you wont get login screen
#
# List of IPs access to Plex without auth
geo $geo {
default 0;
127.0.0.1/32 1;
8.8.8.8/32 1;
}
server {
listen 8080 default_server;
location / {
proxy_set_header Host 192.168.0.50;
proxy_set_header Referer 192.168.0.50;
proxy_set_header Origin 192.168.0.50;
proxy_set_header X-Real-IP 192.168.0.50;
proxy_set_header X-Forwarded-For 192.168.0.50;
proxy_set_header X-Forwarded-Proto $scheme;
#Websockets
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_bind 192.168.0.50;
proxy_buffering off;
if ($geo = 1) {
proxy_pass http://192.168.0.50:32400;
}
}
}
@gbolo
Copy link

gbolo commented Mar 7, 2019

nice :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment