server { listen 80; server_name 192.168.1.17 localhost; # 前端静态文件 location / { root /home/yangfei/mqtt-vue-dashboard/frontend/dist; index index.html; try_files $uri $uri/ /index.html; } # 后端API代理 location /api { proxy_pass http://localhost:3002; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection upgrade; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } # WebSocket代理 location /socket.io { proxy_pass http://localhost:3002; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection upgrade; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } }