worker_processes auto; pid /tmp/nginx.pid; # 非特权用户可写 events { worker_connections 1024; } http { # 设置非特权用户可写的临时路径 client_body_temp_path /tmp/client_body; proxy_temp_path /tmp/proxy_temp; fastcgi_temp_path /tmp/fastcgi_temp; include /etc/nginx/mime.types; # 定义 WebSocket 升级映射(更优雅的写法) map $http_upgrade $connection_upgrade { default upgrade; '' close; } server { listen 7860; server_name localhost; # 根目录反代 8080 (C/C++ 服务) location / { proxy_pass http://127.0.0.1:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } # /bot 路径反代 8888 (Python 服务) location /bot { proxy_pass http://127.0.0.1:8888; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } } }