# Plex behind NginX Reverse Proxy, lost remote access

**URL:** <https://forums.plex.tv/t/plex-behind-nginx-reverse-proxy-lost-remote-access/478005>\
**Category:** Remote Access\
**Tags:** server-docker\
**Created:** [October 18, 2019, 2:32pm UTC](https://forums.plex.tv/t/plex-behind-nginx-reverse-proxy-lost-remote-access/478005 "2019-10-18T14:32:59Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Requiem240sx](https://avatars.discourse-cdn.com/v4/letter/r/ad7895/32.png) [@Requiem240sx](https://forums.plex.tv/u/Requiem240sx)\
**Post date:** [October 18, 2019, 2:32pm UTC](https://forums.plex.tv/t/plex-behind-nginx-reverse-proxy-lost-remote-access/478005/1 "2019-10-18T14:32:59Z")

</div>

Server Version#: 1.17.0.1841  
Player Version#: 3.108.2 (web client)

Here is my issue, my ISP is double Nat’ing me. They did finally set up my internal IP with a port forward for 32400 to my IP, I then port forwarded that to my server. It took them 2 years to open the port… so I really don’t want to go back through them again. So at the moment I only have 1 Public IP, that is limited to a specific port. (I can not use 2 different ports, they will all have to be under the same ip/port)

I’ve been itching to be able to get other web apps through my terrible internet provider, so I can access stuff externally, so I recently setup and configured an NginX reverse proxy that is looking for specific sub domains and redirecting to the correct port internally.

When I set this up, I can now access Plex in a web interface, along with any/all other applications I need so I was very excited. Until I opened up my Plex phone app and it can’t connect anymore. Reading online it appears I have to have an entire port open specifically Plex without a reverse proxy in between it, as its calling out to direct.plex URL’s?

So my question is… is it even possibly to user a reverse proxy with a custom URL and have it directly connect to my server for remote access? It seams like plex doesn’t care about DNS names, and only looks at my public IP (\*Which remember is “our” public IP, as I get to share it with who knows how many other customers).

---

<div class="post-metadata">

**Author:** ![pl\_5309](https://avatars.discourse-cdn.com/v4/letter/p/2bfe46/32.png) [@pl\_5309](https://forums.plex.tv/u/pl_5309)\
**Post date:** [October 18, 2019, 2:53pm UTC](https://forums.plex.tv/t/plex-behind-nginx-reverse-proxy-lost-remote-access/478005/2 "2019-10-18T14:53:35Z")

</div>

The “Custom server access URL’s” under settings\>network

> **[Network | Plex Support](https://support.plex.tv/articles/200430283-network/)**
>
> These are network-related settings for your Plex Media Server. You can access these under Settings \> Server \> Network in...

---

<div class="post-metadata">

**Author:** ![Requiem240sx](https://avatars.discourse-cdn.com/v4/letter/r/ad7895/32.png) [@Requiem240sx](https://forums.plex.tv/u/Requiem240sx)\
**Post date:** [October 18, 2019, 3:02pm UTC](https://forums.plex.tv/t/plex-behind-nginx-reverse-proxy-lost-remote-access/478005/3 "2019-10-18T15:02:22Z")

</div>

Thank you, I did see that and it is set. Is there any info on troubleshooting this further?

Also I did try using my own custom cert on Plex (added the pfx etc…) but I don’t believe it is needed, as nginx is handling the SSL portion, it is also set to “preferred” while testing things out.  
Disclaimer, nginx hands out the cert fine and I don’t get any errors scanning externally or hitting it. SO I don’t believe it is SSL related.

---

<div class="post-metadata">

**Author:** ![nokdim](https://avatars.discourse-cdn.com/v4/letter/n/7ab992/32.png) [@nokdim](https://forums.plex.tv/u/nokdim)\
**Post date:** [October 18, 2019, 3:18pm UTC](https://forums.plex.tv/t/plex-behind-nginx-reverse-proxy-lost-remote-access/478005/4 "2019-10-18T15:18:17Z")

</div>

I also run Nginx and forward a bunch of sites on port 443 but I do not have Plex setup in Nginx as I ran into issues with it like you are having.

Plex for remote access uses a URL like below which uses a cert generated by Plex unique to your external IP which gets tied back in the Plex “cloud” that makes things work seamlessly.

When you use Nginx you dont have that “plex.direct” cert loaded which probably beaks remote access.

![image](https://global.discourse-cdn.com/plex/original/3X/d/c/dc2fe97bfb82566b5a3323bd64f8898fb494d35e.png)

Maybe someone else can chime in and provide some insight but I do not believe it is possible to forward Plex using Nginx and use remote access.

---

<div class="post-metadata">

**Author:** ![Requiem240sx](https://avatars.discourse-cdn.com/v4/letter/r/ad7895/32.png) [@Requiem240sx](https://forums.plex.tv/u/Requiem240sx)\
**Post date:** [October 18, 2019, 3:25pm UTC](https://forums.plex.tv/t/plex-behind-nginx-reverse-proxy-lost-remote-access/478005/5 "2019-10-18T15:25:24Z")

</div>

I believe everything you said is correct,

I was thinking I may be able to proxy forward any plex.direct streams to my server as well. That way it passes through, however it really shouldn’t need to use the plex.direct links at all, since I have my own domain forwarded and SSL is valid. I would love to get more info on this and test things out. The server logs are not showing very useful information.

---

<div class="post-metadata">

**Author:** ![hthighway](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/hthighway/32/82003_2.png) [@hthighway](https://forums.plex.tv/u/hthighway)\
**Post date:** [October 18, 2019, 3:27pm UTC](https://forums.plex.tv/t/plex-behind-nginx-reverse-proxy-lost-remote-access/478005/6 "2019-10-18T15:27:00Z")

</div>

If you’re using something like docker, then look into jwilder/nginx-proxy + jrcs/letsencrypt-nginx-proxy-companion … is an easy solution because it creates nginx config / certs automatically for every other container

and it is very possible (as it it works 100% of the time) to forward plex using Nginx and use remote access

---

<div class="post-metadata">

**Author:** ![Requiem240sx](https://avatars.discourse-cdn.com/v4/letter/r/ad7895/32.png) [@Requiem240sx](https://forums.plex.tv/u/Requiem240sx)\
**Post date:** [October 18, 2019, 3:30pm UTC](https://forums.plex.tv/t/plex-behind-nginx-reverse-proxy-lost-remote-access/478005/7 "2019-10-18T15:30:59Z")

</div>

I’m already using something similiar to automate SSL and configs. It is %100 accessible from off my network if I hit my domain:port.

My issue is that [plex.tv](http://plex.tv) is not seeing it… so though my web browser is working great, when I open my Plex iphone app, it fails to see it… since “remote access” can’t be used.

If i change my port forward rule in my router to point directly to my PMS Docker container, it works great, if I point it to NginX, which direct it to Plex it ruins it.

---

<div class="post-metadata">

**Author:** ![hthighway](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/hthighway/32/82003_2.png) [@hthighway](https://forums.plex.tv/u/hthighway)\
**Post date:** [October 18, 2019, 3:39pm UTC](https://forums.plex.tv/t/plex-behind-nginx-reverse-proxy-lost-remote-access/478005/8 "2019-10-18T15:39:13Z")

</div>

What does your plex YML file look like?  
Do you have any of the following defined?

```auto
    environment:
      - VIRTUAL_HOST=<domain name if using one>
      - VIRTUAL_PORT=32400
      - VIRTUAL_NETWORK=nginx-proxy
    expose:
      - 32400

```

---

<div class="post-metadata">

**Author:** ![hthighway](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/hthighway/32/82003_2.png) [@hthighway](https://forums.plex.tv/u/hthighway)\
**Post date:** [October 18, 2019, 3:41pm UTC](https://forums.plex.tv/t/plex-behind-nginx-reverse-proxy-lost-remote-access/478005/9 "2019-10-18T15:41:51Z")

</div>

There is also info here that could be useful for you

> **[toomuchio/plex-nginx-reverseproxy](https://github.com/toomuchio/plex-nginx-reverseproxy)**
>
> Configuration to serve Plex Media Center https://plex.tv using Nginx https://nginx.com - toomuchio/plex-nginx-reverseproxy

---

<div class="post-metadata">

**Author:** ![Requiem240sx](https://avatars.discourse-cdn.com/v4/letter/r/ad7895/32.png) [@Requiem240sx](https://forums.plex.tv/u/Requiem240sx)\
**Post date:** [October 18, 2019, 3:44pm UTC](https://forums.plex.tv/t/plex-behind-nginx-reverse-proxy-lost-remote-access/478005/10 "2019-10-18T15:44:18Z")

</div>

> [@hthighway](#):
>
> - VIRTUAL\_HOST= - VIRTUAL\_PORT=32400 - VIRTUAL\_NETWORK=nginx-proxy

I did not have any of these environment variables so I added them and gave it a restart. Doesn’t appear to have helped. Here is my docker-compose plex portion:

```auto
  plex:
    container_name: plex
    image: linuxserver/plex:latest
    restart: unless-stopped
    devices:
      - /dev/dri:/dev/dri # For hardware acceleration
    environment:
      - ADVERTISE_IP=https://plex.mydomain.com:32400/
      - PLEX_CLAIM=claim-<claim code>
      - TZ=${TZ} # timezone, defined in .env
      - PUID=${PUID} # default user id, defined in .env
      - PGID=${PGID} # default group id, defined in .env
      - VIRTUAL_HOST=plex.<domain.com>
      - VIRTUAL_PORT=32400
      - VIRTUAL_NETWORK=nginx-proxy
    volumes:
      - ${ROOT}/plex/config/:/config # plex database
      - ${ROOT}/plex/transcode:/transcode # temp transcoded files
      - ${MEDIA}:/data # media library
      - ${CERT}:/cert
    ports:
      - 32400:32400/tcp
      - 3005:3005/tcp
      - 8324:8324/tcp
      - 32469:32469/tcp
      - 1900:1900/udp
      - 32410:32410/udp
      - 32412:32412/udp
      - 32413:32413/udp
      - 32414:32414/udp
    networks:
      - media
      - proxy
```

---

<div class="post-metadata">

**Author:** ![hthighway](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/hthighway/32/82003_2.png) [@hthighway](https://forums.plex.tv/u/hthighway)\
**Post date:** [October 18, 2019, 3:52pm UTC](https://forums.plex.tv/t/plex-behind-nginx-reverse-proxy-lost-remote-access/478005/11 "2019-10-18T15:52:09Z")

</div>

VIRTUAL\_NETWORK = should point to one of the networks listed under

```auto
 networks:
      - media
      - proxy

```

I don’t use ADVERTISE\_IP, but shouldn’t that point to `https://plex.mydomain.com:443` or what ever secure PORT you are using?

---

<div class="post-metadata">

**Author:** ![hthighway](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/hthighway/32/82003_2.png) [@hthighway](https://forums.plex.tv/u/hthighway)\
**Post date:** [October 18, 2019, 3:53pm UTC](https://forums.plex.tv/t/plex-behind-nginx-reverse-proxy-lost-remote-access/478005/12 "2019-10-18T15:53:53Z")

</div>

and in your plex settings under  
Settings-\>Network what do you have in the `Custom server access URLs` field?  
It should be your `https://plex.mydomain.com`

---

<div class="post-metadata">

**Author:** ![Requiem240sx](https://avatars.discourse-cdn.com/v4/letter/r/ad7895/32.png) [@Requiem240sx](https://forums.plex.tv/u/Requiem240sx)\
**Post date:** [October 18, 2019, 3:54pm UTC](https://forums.plex.tv/t/plex-behind-nginx-reverse-proxy-lost-remote-access/478005/13 "2019-10-18T15:54:57Z")

</div>

I tried removing advertise ip, dropped in my “proxy” network and still no luck.

---

<div class="post-metadata">

**Author:** ![Requiem240sx](https://avatars.discourse-cdn.com/v4/letter/r/ad7895/32.png) [@Requiem240sx](https://forums.plex.tv/u/Requiem240sx)\
**Post date:** [October 18, 2019, 4:04pm UTC](https://forums.plex.tv/t/plex-behind-nginx-reverse-proxy-lost-remote-access/478005/14 "2019-10-18T16:04:13Z")

</div>

I have it set to [https://plex.mydomain.com:32400](https://plex.mydomain.com:32400)

My domain name points to my public IP, but if the port is not specified there it will not route properly through to me (since I’m double nat). Is that going to be an issue?

Also sounds like you have tested this before, can you confirm that you have got a reverse proxy with [plex.tv](http://plex.tv) remote access both working?

---

<div class="post-metadata">

**Author:** ![hthighway](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/hthighway/32/82003_2.png) [@hthighway](https://forums.plex.tv/u/hthighway)\
**Post date:** [October 18, 2019, 4:06pm UTC](https://forums.plex.tv/t/plex-behind-nginx-reverse-proxy-lost-remote-access/478005/15 "2019-10-18T16:06:39Z")

</div>

yes, I have plex behind an nginx reverse-proxy and remote access works great, it has to as my box is remote to me 100% of the time. It’s in a datacenter 🙂

I haven’t set it up behind a consumer router in a very long time, but you are probably missing pieces in your nginx YML as well.

Which is why I reference the jwilder/nginx-proxy stuff.

Also, depending on how attached you are to your current setup…  
I’d also suggest looking at [GitHub - Cloudbox/Cloudbox: Ansible-based solution for rapidly deploying a Docker containerized cloud media server.](https://github.com/Cloudbox/Cloudbox)  
It can automate nearly all of the config and setup for you

---

<div class="post-metadata">

**Author:** ![Requiem240sx](https://avatars.discourse-cdn.com/v4/letter/r/ad7895/32.png) [@Requiem240sx](https://forums.plex.tv/u/Requiem240sx)\
**Post date:** [October 18, 2019, 4:21pm UTC](https://forums.plex.tv/t/plex-behind-nginx-reverse-proxy-lost-remote-access/478005/16 "2019-10-18T16:21:55Z")

</div>

Thank you for confirming, everything I read online was years ago so I wasn’t positive.

I would love to host externally, however I can’t. My internet download speeds are only 35mbps, and I have recently started doing 4K/HDR content. It would be extremely hard to do that. I also just upgrade my server and already have 24tb of storage, so my up front cost is already done.

I do not believe it is my router configs, so my ISP port forwards publicip:32400 to my staticip:32400.  
I then port forward 32400 to my server on 32400 (for plex directly) and it works great.  
I can also port forward to 443 (for nginx) and it breaks everything… but all my proxy stuff works and its still available externally, just not [plex.tv](http://plex.tv) remote access.

That leaves us down to either a plex configuration issue, or an nginx issue. I used the linuxserver lets encrypt image, that has built in nginx and cerbot for ssl etc…

---

<div class="post-metadata">

**Author:** ![nokdim](https://avatars.discourse-cdn.com/v4/letter/n/7ab992/32.png) [@nokdim](https://forums.plex.tv/u/nokdim)\
**Post date:** [October 18, 2019, 5:23pm UTC](https://forums.plex.tv/t/plex-behind-nginx-reverse-proxy-lost-remote-access/478005/17 "2019-10-18T17:23:24Z")

</div>

IDK I messed with this for the last couple hours with no success.

I can setup the PFX and get to [https://plex.mydomain.com](https://plex.mydomain.com) with no errors  
Once I tell Plex remote access to use port 443 instead of 32400 it just shows Not Available Outside

Ill keep jacking with this and see if I get any success.

BTW I am using linux server dockers for both Plex and Letsencrypt.

---

<div class="post-metadata">

**Author:** ![Requiem240sx](https://avatars.discourse-cdn.com/v4/letter/r/ad7895/32.png) [@Requiem240sx](https://forums.plex.tv/u/Requiem240sx)\
**Post date:** [October 21, 2019, 6:16pm UTC](https://forums.plex.tv/t/plex-behind-nginx-reverse-proxy-lost-remote-access/478005/18 "2019-10-21T18:16:26Z")

</div>

Yes I have got the PFX to work as well, it didn’t seam to change anything. I believe I’m going to have to have 2 ports open to do this, 1 for a direct connection to my server (no reverese proxy) and another for my proxy.  
Seams weird that it can’t directly connect through the proxy though. I’m down at Splunk Conf, so I have not had any time to play with it more, but next week I’ll for sure be back at it, hopefully can figure out a solution, been think of some things to test  
Also, I’m using linuxserverio images (both for plex and letsencrypt)

---

<div class="post-metadata">

**Author:** ![Blockost](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/blockost/32/160348_2.png) [@Blockost](https://forums.plex.tv/u/Blockost)\
**Post date:** [November 19, 2019, 8:38pm UTC](https://forums.plex.tv/t/plex-behind-nginx-reverse-proxy-lost-remote-access/478005/19 "2019-11-19T20:38:21Z")

</div>

Hi, I’m also setting up Plex on a server I rent in a datacenter and I’m having troubles making remote access work with Nginx.

Can you post the relevant docker-compose configuration or whatever conf you are using to make it work properly?

---

<div class="post-metadata">

**Author:** ![Requiem240sx](https://avatars.discourse-cdn.com/v4/letter/r/ad7895/32.png) [@Requiem240sx](https://forums.plex.tv/u/Requiem240sx)\
**Post date:** [November 20, 2019, 12:00am UTC](https://forums.plex.tv/t/plex-behind-nginx-reverse-proxy-lost-remote-access/478005/20 "2019-11-20T00:00:16Z")

</div>

So I believe I got this working just fine. My issue was that I can’t test from my work VPN or from my internal network… so if I hotspot to my phone it works fine. Kind of weird rules internally and through work.  
Anyways, this is my config files, I did it with sub domains [plex.domain.com](http://plex.domain.com) instead of the [domain.com/plex](http://domain.com/plex) at the end etc… but both ways are possible.

docker-compose file for nginx

```auto
  nginx:
    image: linuxserver/letsencrypt
    container_name: nginx
    environment:
      - PUID=${PUID}
      - PGID=${PGID}
      - TZ=${TZ}
      - URL=<yourdomain.com>
      - SUBDOMAINS=plex,www
      - VALIDATION=dns
      - DNSPLUGIN=<enter plugin type here>
      - EMAIL=<enter your email>
      - DHLEVEL=4096
    volumes:
      - ${ROOT}/nginx:/config
    ports:
      - 80:80
      - 443:443
    networks:
      - proxy
      - network
    restart: unless-stopped

# networks
networks:
  proxy:
    name: proxy
  network:
    name: network

```

_In addition to this, I have .env variables set for all the PUID/PGID/TZ and ROOT._

So in my nginx folder above, there is another folder called nginx, and then a site-confs. Simply create a plex.conf tile, and this is my plex conf file. I have others as well. I left the default file as well, but emptied the file so that it didn’t set stuff I didn’t want.

/nginx/nginx/site-confs

```auto
upstream plex {
  server plex:32400; #note i simply used "plex" since it is the containers name, and it is on the same network as nginx so it can simply use this. If not you can use the IP address. 
}

server {
    listen 80;
    server_name <plex.yourdomain.com>;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2 default_server;
    server_name plex.<yourdomain.com>;

    send_timeout 100m; #Some players don't reopen a socket and playback stops totally instead of resuming after an extended pause (e.g. Chrome)

    ssl_certificate /config/etc/letsencrypt/live/<yourdomain>.com/cert.pem;
    ssl_certificate_key /config/etc/letsencrypt/live/<yourdomain>.com/privkey.pem;
    ssl_trusted_certificate /config/etc/letsencrypt/live/<yourdomain>.com/chain.pem;

    ssl_protocols TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-#SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GC#M-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA#-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SH#A384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-A#ES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA#-AES256-SHA:ECDHE-RSA-DES-CBC3-SHA:ECDHE-ECDSA-DES-CBC3-SHA:AES128-GCM-SHA256:AE#S256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:D#ES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-S#HA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';

    ssl_stapling on;
    ssl_stapling_verify on;
    ssl_session_tickets on;

    access_log /config/log/nginx/<yourdomain>.com.access.log;
    error_log /config/log/nginx/<yourdomain>.com.error.log;

    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]\.";

    client_max_body_size 100M;

    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;

    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";

    proxy_set_header Accept-Encoding "";

    proxy_redirect off;

    proxy_buffering off;
    location / {
         proxy_pass https://plex;
}

}

```

I tried breaking apart both nginx and letsencrypt portions, and ran into a lot of headache… this image combines them both into 1 and it makes it much easier to setup IMO.

[Next page](https://forums.plex.tv/t/plex-behind-nginx-reverse-proxy-lost-remote-access/478005.md?page=2)
