Plex Behind a Reverse Proxy: Nginx and Caddy Setup
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 adds HTTPS encryption, lets you use a custom domain name, enables access on standard ports (443 instead of 32400), and adds security features that Plex alone does not provide. It is the recommended setup for anyone serious about remote access security.
Why use a reverse proxy with Plex
Running Plex with direct port forwarding works, but a reverse proxy solves several problems:
- HTTPS encryption: Plex supports HTTPS through its own servers, but the connection between your client and your server can fall back to HTTP in some configurations. A reverse proxy with a proper SSL certificate ensures all traffic is encrypted end-to-end
- Standard ports: Port 32400 is blocked by some corporate firewalls and public WiFi networks. A reverse proxy lets you serve Plex on port 443 (standard HTTPS), which is almost never blocked
- Custom domain: Instead of accessing your server via an IP address and port number, use a clean URL like plex.yourdomain.com. This is easier to remember and looks more professional when sharing with friends and family
- Security headers: A reverse proxy can add HTTP security headers (HSTS, X-Frame-Options, Content-Security-Policy) that harden your server against common web attacks. Plex does not add these headers by default
- Centralized access: If you run multiple services (Plex, Overseerr, Tautulli), a single reverse proxy can serve them all on different subdomains with one SSL certificate, one entry point, and consistent security settings
Caddy setup (recommended for beginners)
Caddy is the easiest reverse proxy to configure because it handles HTTPS certificates automatically — no manual certificate management required:
- Install Caddy: On Ubuntu/Debian:
sudo apt install caddy. On Docker: use thecaddy:latestimage. Caddy runs as a system service and starts automatically on boot - DNS setup: Point your domain (like plex.yourdomain.com) to your server's public IP. If your IP is dynamic, use a DDNS service and point the domain to that hostname via a CNAME record
- Caddyfile configuration: Create or edit the Caddyfile (usually at /etc/caddy/Caddyfile). The configuration is minimal — specify the domain and the upstream address. Caddy automatically obtains and renews a Let's Encrypt certificate for the domain
- WebSocket support: Plex uses WebSocket connections for real-time features (Now Playing updates, remote control). Caddy proxies WebSocket connections by default — no additional configuration needed
- Large file headers: Add a header configuration to increase the maximum request size. Plex uploads can include large artwork files, and the default limits may be too small. Set the request body size to at least 100 MB
Nginx setup
Nginx is more configurable than Caddy but requires manual SSL certificate management (usually via Certbot):
- Install Nginx and Certbot: On Ubuntu:
sudo apt install nginx certbot python3-certbot-nginx. This installs Nginx and the Let's Encrypt certificate tool that integrates with Nginx - Server block configuration: Create a new Nginx configuration file for Plex. The key directives are:
proxy_pass http://127.0.0.1:32400to forward requests to Plex, WebSocket upgrade headers (proxy_set_header Upgrade $http_upgradeandproxy_set_header Connection "upgrade"), and appropriate proxy buffer sizes for media streaming - SSL with Certbot: Run
sudo certbot --nginx -d plex.yourdomain.comto automatically obtain a certificate and configure Nginx to use it. Certbot adds the SSL configuration to your server block and sets up automatic renewal - Proxy headers: Set
proxy_set_header Host $host,proxy_set_header X-Real-IP $remote_addr, andproxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for. These headers tell Plex the real client IP instead of the proxy's IP, which is important for access logs and network-based access rules - Buffering settings: Disable proxy buffering for streaming (
proxy_buffering off) to allow media data to flow through without being stored in memory. Setproxy_read_timeout 86400sandproxy_send_timeout 86400sto prevent long-running streams from being cut off by timeout
Nginx Proxy Manager (GUI option)
For users who prefer a web interface over editing configuration files, Nginx Proxy Manager wraps Nginx in a user-friendly dashboard:
- What it is: A Docker container that provides a web UI for managing Nginx reverse proxy configurations. It handles SSL certificates, proxy hosts, and access lists through a point-and-click interface
- Setup: Run the Nginx Proxy Manager container via Docker Compose. Access the web UI on port 81. Add a new proxy host: set the domain, forward hostname to your Plex server's IP, forward port to 32400, and enable WebSocket support. Click the SSL tab and request a new certificate — it uses Let's Encrypt automatically
- Trade-offs: Easier to set up than raw Nginx, but adds another Docker container to manage. The web UI is convenient for occasional changes but less flexible than editing config files directly for advanced configurations
Plex server configuration
After setting up the reverse proxy, configure Plex to work with it:
- Custom server access URL: In Plex Settings, Network, set the "Custom server access URLs" to your proxy URL (like https://plex.yourdomain.com:443). This tells Plex clients to connect through the proxy instead of trying direct connections on port 32400
- Secure connections: In Plex Settings, Network, set "Secure connections" to Preferred or Required. With a reverse proxy handling HTTPS, this ensures all connections are encrypted
- Allowed networks: If your reverse proxy runs on the same machine as Plex, add the proxy's IP (127.0.0.1) to the "List of IP addresses and networks that are allowed without auth" so the proxy can reach Plex without authentication issues
- Remote access: You can disable Plex's built-in remote access feature since the reverse proxy handles incoming connections. This closes port 32400 to the internet — only the proxy's ports (80 and 443) need to be open. Some users keep both enabled as a fallback
SSL certificate management
HTTPS requires a valid SSL certificate. Here are the options:
- Let's Encrypt (recommended): Free, automatically issued and renewed. Both Caddy and Certbot handle this automatically. Certificates are valid for 90 days and auto-renew before expiration
- Cloudflare proxy: If your domain uses Cloudflare DNS, you can enable Cloudflare's proxy to get free SSL. Traffic is encrypted between the client and Cloudflare, and between Cloudflare and your server (with an origin certificate). This adds Cloudflare's CDN and DDoS protection as a bonus
- Self-signed certificates: Not recommended for Plex because most clients will show security warnings or refuse to connect. Use Let's Encrypt instead — it is free and produces universally trusted certificates
Troubleshooting
- 502 Bad Gateway: The reverse proxy cannot reach Plex. Verify Plex is running and accessible on port 32400 from the proxy host. Check that the proxy_pass address is correct (127.0.0.1:32400 if on the same machine, or the LAN IP if on a different machine)
- WebSocket errors: Plex features like Now Playing and remote control stop working. Verify WebSocket upgrade headers are configured in the proxy. In Nginx, both Upgrade and Connection headers must be set. In Caddy, WebSocket proxying works by default
- Plex says not secure: Check that the SSL certificate is valid and not expired. Verify the Custom server access URL in Plex uses https:// and matches the domain on the certificate
- Large file upload fails: Increase the client_max_body_size in Nginx (default is 1 MB, too small for artwork uploads). In Caddy, adjust the request_body max_size
- Streams buffer through proxy: Disable proxy buffering. Enable proxy_request_buffering off in Nginx. Ensure the proxy server has enough bandwidth to handle the media throughput — the proxy becomes a bottleneck if it cannot forward data as fast as Plex sends it