#front-end server { listen 8000; server_name localhost; location / { root /tmp/front_work_dir; index index.html index.htm; } #error_page 404 /404.html; } # 反向代理 front-end 和 back-end server { listen 80; listen [::]:80; server_name onlyyounotothers.top www.onlyyounotothers.top; # http 重定向到 https return 301 https://onlyyounotothers.top$request_uri; location / { root html; index index.html index.htm; proxy_pass http://localhost:8000/; } location /api/ { rewrite ^/b/(.*)$ /$1 break; # 去除本地接口/api前缀, 否则会出现404 proxy_pass http://110.40.137.191:3000/; } }