You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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_processes to match your CPU core count for better performance (e.g., 2 for dual-core, 4 for quad-core).
  • Plex Server Block: Added a dedicated server block 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.1 and upgrade headers ensure Plex's real-time features (like playback controls) work without issues.
  • Plex Path Coverage: The secondary location block ensures all Plex-specific endpoints are routed correctly, preventing broken UI elements or playback failures.

Post-Configuration Steps

  1. Update Placeholders: Replace your-server-domain-or-ip with your actual server's public domain name or IP address.
  2. Validate Config: Open a command prompt in your Nginx directory (e.g., C:\nginx) and run:
    nginx.exe -t
    
    If you see "test is successful", your config is syntax-free.
  3. Restart Nginx: Apply changes with this command:
    nginx.exe -s reload
    
  4. Test Access: Visit http://your-server-domain-or-ip in 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 listen to 443 ssl and add ssl_certificate/ssl_certificate_key directives pointing to your certificate files.

内容的提问来源于stack exchange,提问作者Lindsey B

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 12:08:26