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; access_log /dev/stdout; error_log /dev/stderr; include /etc/nginx/mime.types; #include /etc/nginx/conf.d/*.conf; # 定义 WebSocket 升级映射(更优雅的写法) map $http_upgrade $connection_upgrade { default upgrade; '' close; } server { listen 7860; server_name 0.0.0.0; # 根目录反代 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; } } }