Windows服务器上Nginx.conf配置文件无法为Plex正常工作
Fixing Nginx Configuration for Plex on Windows Server
Looks like your current Nginx config only has the basic HTTP framework but is missing all the critical reverse proxy logic needed to route traffic to your Plex server. Let's fix that up with a working, tailored configuration.
Complete Working Configuration
Replace your existing nginx.conf with this adjusted version (optimized for Windows and Plex):
#user nobody; # Match worker_processes to your CPU core count (e.g., 4 for a quad-core server) worker_processes 2; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log logs/access.log main; sendfile on; keepalive_timeout 65; # Plex Reverse Proxy Server Block server { # Listen on standard HTTP port (swap to 443 if using SSL) listen 80; # Replace with your server's public domain or IP address server_name your-server-domain-or-ip; # Main Plex route handles core traffic location / { proxy_pass http://localhost:32400; 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; # Enable WebSocket support for Plex's real-time features proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } # Catch-all for Plex-specific endpoints to avoid broken UI/playback location ~ ^/(web|video|photo|library|system|services|friends|search|status|playQueues|transcode|identity) { proxy_pass http://localhost:32400; 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; } } }
Key Changes & Explanations
- Worker Processes: Adjust
worker_processesto match your CPU core count for better performance (e.g., 2 for dual-core, 4 for quad-core). - Plex Server Block: Added a dedicated
serverblock to route incoming traffic to Plex's default port (32400). - Proxy Headers: Plex relies on these headers to correctly identify request sources and handle secure connections (critical if you add SSL later).
- WebSocket Support: The
proxy_http_version 1.1and upgrade headers ensure Plex's real-time features (like playback controls) work without issues. - Plex Path Coverage: The secondary
locationblock ensures all Plex-specific endpoints are routed correctly, preventing broken UI elements or playback failures.
Post-Configuration Steps
- Update Placeholders: Replace
your-server-domain-or-ipwith your actual server's public domain name or IP address. - Validate Config: Open a command prompt in your Nginx directory (e.g.,
C:\nginx) and run:
If you see "test is successful", your config is syntax-free.nginx.exe -t - Restart Nginx: Apply changes with this command:
nginx.exe -s reload - Test Access: Visit
http://your-server-domain-or-ipin your browser – you should land on the Plex login page.
Troubleshooting Tips
- If you get a 502 Bad Gateway, confirm Plex is running and listening on port
32400(check Plex Settings > Network). - Ensure Windows Firewall allows incoming traffic on port 80 (or 443 if using SSL) and that Nginx has network access permissions.
- For SSL, switch
listento443 ssland addssl_certificate/ssl_certificate_keydirectives pointing to your certificate files.
内容的提问来源于stack exchange,提问作者Lindsey B
相关产品推荐
相关产品推荐

