server {
listen 40000;
server_name localhost;
location / {
root /usr/local/前端项目目录;
try_files $uri $uri/ /index.html;
index index.html index.html;
# 接口代理地址,如果你需要通过代理转发请求
location /dwq {
proxy_pass http://10.168.2.10:4444;
rewrite ^.+dwq/?(.*)$ /$1 break; # 去除本地接口/api前缀, 否则会出现404
}
}
# 解决 nginx 禁止post请求问题,需要后台配置跨域
# error_page 405 =200 http://$host$request_uri;
}