我有一个nginx代理请求到Ubuntu框后端的node.js web应用程序。对于带有url空格的api.example.com请求,会收到400错误的请求错误。认为问题的代码行是:
proxy_pass http://127.0.0.1:3002$uri$is_args$query_string;
然而不确定如何重写它。
这是/ etc / nginx / sites-available / default中的站点配置的外观:
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
server {
listen 80;
server_name api.example.com;
location / {
proxy_pass http://127.0.0.1:3002$uri$is_args$query_string;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}