Set Up a Reverse Proxy for Plex With Nginx and SSL
Published 2026-10-16 · PlexBeam
A reverse proxy sits between the internet and your Plex server, handling incoming connections and forwarding them to Plex. This provides a custom domain name, free TLS certificates, centralized access logging, and the ability to run multiple services behind one public IP. This guide covers setting up Nginx as a reverse proxy for Plex with automatic SSL from Let's Encrypt.
Why Use a Reverse Proxy for Plex
- Custom domain: Access Plex at
plex.yourdomain.cominstead ofyour-ip:32400. - Automatic SSL: Let's Encrypt provides free TLS certificates with auto-renewal. All traffic between clients and your server is encrypted without relying on Plex's built-in certificates.
- Single port: Run Plex, Overseerr, Tautulli, and other services behind one reverse proxy on port 443. No need to open multiple ports on your firewall.
- Access control: Add basic authentication, IP allowlists, rate limiting, or fail2ban integration at the proxy level before traffic reaches Plex.
- Logging: Centralized access logs for all services in one place.
Prerequisites
- A domain name you own (registered through any registrar).
- DNS A record pointing your subdomain (e.g.,
plex.yourdomain.com) to your server's public IP. - A Linux server with Nginx installed (can be the same machine as Plex or a separate machine on the same network).
- Certbot installed for automatic Let's Encrypt certificate management.
Installing Nginx and Certbot
On Ubuntu/Debian:
sudo apt update
sudo apt install nginx certbot python3-certbot-nginx
On RHEL/Rocky/Alma:
sudo dnf install nginx certbot python3-certbot-nginx
Start and enable Nginx:
sudo systemctl enable --now nginx
Nginx Configuration for Plex
Create a configuration file for your Plex subdomain:
sudo nano /etc/nginx/sites-available/plex.yourdomain.com
Add the following configuration:
upstream plex_backend {
server 127.0.0.1:32400;
keepalive 32;
}
server {
listen 80;
server_name plex.yourdomain.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name plex.yourdomain.com;
send_timeout 100m;
client_max_body_size 100M;
ssl_certificate /etc/letsencrypt/live/plex.yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/plex.yourdomain.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
gzip on;
gzip_vary on;
gzip_min_length 1000;
gzip_types text/plain text/css text/xml application/xml application/javascript application/json;
location / {
proxy_pass http://plex_backend;
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_buffering off;
proxy_redirect off;
}
}
Key directives explained:
- upstream with keepalive: Maintains persistent connections to Plex, reducing latency for repeated requests.
- proxy_buffering off: Essential for streaming. Buffering causes video playback to stall while Nginx buffers the entire response.
- WebSocket headers (Upgrade, Connection): Plex uses WebSockets for real-time features (companion, remote control, live updates). Without these headers, remote control and sync features break.
- send_timeout 100m: Long timeout for streaming sessions that last hours.
- client_max_body_size 100M: Allows large uploads (poster images, subtitles).
Enabling the Site and Getting SSL
Create a symlink to enable the configuration:
sudo ln -s /etc/nginx/sites-available/plex.yourdomain.com /etc/nginx/sites-enabled/
Test the configuration:
sudo nginx -t
Obtain a certificate from Let's Encrypt:
sudo certbot --nginx -d plex.yourdomain.com
Certbot automatically modifies your Nginx configuration to use the certificate and sets up auto-renewal via a systemd timer. Certificates renew automatically every 60 days.
Reload Nginx:
sudo systemctl reload nginx
Configuring Plex to Work With the Proxy
Plex needs to know it is behind a reverse proxy:
- Go to Settings > Network.
- Custom server access URLs: Add
https://plex.yourdomain.com:443. This tells Plex clients to connect through the proxy. - List of IP addresses and networks that are allowed without auth: Add your Nginx server's IP if it is on a different machine (e.g.,
192.168.1.50/32). This prevents Plex from requiring authentication for proxy-forwarded requests. - Treat WAN IP as LAN bandwidth: Enable this if the proxy is on the same network as Plex to prevent unnecessary bandwidth throttling.
SSL Security Hardening
Strengthen the default SSL configuration:
- HSTS header: Add
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";to force browsers to always use HTTPS. - OCSP stapling: Add
ssl_stapling on; ssl_stapling_verify on;for faster certificate validation. - Restrict TLS versions: Only allow TLS 1.2 and 1.3. TLS 1.0 and 1.1 have known vulnerabilities.
Running Multiple Services
The main advantage of a reverse proxy: host multiple services behind one IP. Add additional server blocks for each service:
overseerr.yourdomain.com→ proxy to localhost:5055tautulli.yourdomain.com→ proxy to localhost:8181sonarr.yourdomain.com→ proxy to localhost:8989
Each gets its own Let's Encrypt certificate and its own Nginx server block. All share port 443.
Troubleshooting
WebSocket Errors in Plex Dashboard
If the Plex web interface shows WebSocket connection errors or the companion feature does not work, verify the Upgrade and Connection headers are present in your Nginx configuration. These headers are required for WebSocket passthrough.
Infinite Redirect Loop
If Plex redirects endlessly between HTTP and HTTPS, check that the custom server access URL uses https:// and that Plex's secure connections setting is not set to "Required" while the proxy connects to Plex over HTTP internally. Set Plex's secure connections to "Preferred" when behind a proxy that terminates SSL.
Remote Access Warning Despite Proxy Working
Plex's built-in remote access check tests direct connectivity on port 32400. With a reverse proxy, you may not have port 32400 open — only 443 through Nginx. The remote access warning can be safely ignored if clients connect successfully through the proxy. Alternatively, keep port 32400 forwarded alongside the proxy for compatibility with clients that do not support custom URLs.
Slow Streaming Through Proxy
Ensure proxy_buffering off is set. With buffering on, Nginx tries to buffer the entire video stream before forwarding, causing massive delays. Also verify that gzip is not compressing video streams — it wastes CPU and provides no benefit for already-compressed video data. The gzip_types directive should only list text-based content types.