server { listen 80; listen [::]:80; server_name localhost; location / { root /etc/nginx/html; index index.html index.htm; try_files $uri /index.html; } # 后端跨域请求 location ~/api/ { proxy_pass http://192.168.3.98:1001; } # mock 跨域 location ~/mock/ { proxy_pass http://192.168.3.98:1001; } error_page 404 404.html; location = /50x.html { root html; } }