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
| server { listen 80; // Nginx的监听端口 server_name localhost; // 访问Nginx服务器的域名 location / { root usr/local/vue/page; //前端项目入口文件的路径 try_files $uri $uri/ @router; index index.html index.htm; //前端入口文件为index.html } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location @router { rewrite ^.*$ /index.html last; } location /api { //凡是以/api开头的http请求都会被下面的服务器处理 proxy_pass https: //127.0.0.1:5777; //被代理的服务器的域名 proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }
|