moreNginx 使用技巧On this pageNginx 使用技巧 反向代理时若要忽略某路径前缀,必须注意后面要加 / server { listen 80; # 注意是 `/api/` 不是 `/api`location /api/ { proxy_pass http://localhost:3000/; proxy_set_header Host $http_host;} } 一定要参考默认配置 诸如 PHP 相关的 Nginx 配置,一定要参考 /etc/nginx/sites-enabled/default 文件里面的写法。不同版本的 Nginx 它对 PHP 的配置都有所不同,上网搜的相关 Nginx 配置片段不一定能用。