1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| server { listen 80 default_server; listen [::]:80 default_server;
# Add index.php to the list if you are using PHP index index.html index.htm index.nginx-debian.html;
server_name _;
location ^~ /gateway/ { proxy_pass http://localhost:20000/gateway/; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forward-For $remote_addr; }
location ^~ /oss/ { proxy_pass http://localhost:20011/; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forward-For $remote_addr; }
location ^~ /ws/ { proxy_pass http://localhost:20011/; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forward-For $remote_addr; proxy_http_version 1.1; # 必须设置为1.1以支持WebSocket proxy_set_header Upgrade $http_upgrade; # 设置Upgrade头 proxy_set_header Connection "upgrade"; # 设置Connection头 }
location / { # Vue应用的访问路径; 如果需要配制前缀,例如 /web,需要在Vue应用打包时指定前缀,这样才能反向代理成功 root /home/ubuntu/web/dist; index index.html index.htm; try_files $uri $uri/ /index.html =404; } }
|