I’m running the latest version of Plex Media Server: Version 1.31.2.6810. Under my Plex server’s Network settings, I specified my custom domain names:
Custom server access URLs: https://plex.mydomain.com,https://mediaplex.mydomain.com
However, in Plex’s console log, I keep getting the below message; which I don’t my plex clients to be treated as ‘non-local’
"Request came in with unrecognized domain / IP ‘plex.mydomain.com’ in header Referer; treating as non-local"
I tried using the NGINX config from this Gist Github post and this Gist Github post2; which specifically was meant to handle this issue (at least for an older version of Plex Server). However, it didn’t make any difference.
What am I missing in this configuration?
PS: I have the below setting enabled under Plex’s network settings. I’m not sure if this would cause the issue I’m seeing or not.
☑️ Treat WAN IP As LAN Bandwidth
nginx.conf
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate ./ssl/fullchain.cer;
ssl_certificate_key ./ssl/cert.key;
ssl_prefer_server_ciphers on;
server_name plex.mydomain.com mediaplex.mydomain.com;
client_max_body_size 0;
set $plex http://127.0.0.1:32400;
gzip on;
gzip_vary on;
gzip_min_length 1000;
gzip_proxied any;
gzip_types text/plain text/css text/xml application/xml text/javascript application/x-javascript image/svg+xml;
gzip_disable "MSIE [1-6].";
# Forward real ip and host to Plex
proxy_set_header Host $host;
proxy_set_header Referer $host;
proxy_set_header Origin $host;
proxy_set_header X-Real-IP $remote_addr;
#When using ngx_http_realip_module change $proxy_add_x_forwarded_for to '$http_x_forwarded_for,$realip_remote_addr'
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Plex-Client-Identifier $http_x_plex_client_identifier;
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;
proxy_set_header Cookie $http_cookie;
proxy_set_header Sec-WebSocket-Extensions $http_sec_websocket_extensions;
proxy_set_header Sec-WebSocket-Key $http_sec_websocket_key;
proxy_set_header Sec-WebSocket-Version $http_sec_websocket_version;
# Websockets
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
# Buffering off send to the client as soon as the data is received from Plex.
proxy_redirect off;
proxy_buffering off;
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
# Redirect if not an options request.
if ($request_method != OPTIONS ) {
set $test A;
}
if ($http_x_plex_device_name = '') {
set $test "${test}B";
}
if ($arg_X-Plex-Device-Name = '') {
set $test "${test}C";
}
if ($test = ABC) {
rewrite ^/$ https://$http_host/web/index.html;
}
proxy_pass $plex;
}
}
2
Answers
As you said that 192.168.1.2 works well for you. You can pass it to the plex. So in your nginx config file replace
with:
As per your questions the error message says:
In your nginx config you are explicitly passing the
$host
variable to this header.From the Nginx docs here the host variable will hold:
$host
in this order of precedence: host name from the request line, or host name from the “Host” request header field, or the server name matching a request
It would appear that the value being passed here does not match your configured domain names in the plex config.
You could investigate the value by adding a location block and browsing to it.
If this variable is not set to an appropriate value it might be to worth trying a different var for example
$host_name
You could just explicitly pass localhost or one of your configured server names as the header value.