1

I have nginx proxying requests to a node.js web app in the backend on a Ubuntu box. For requests to api.example.com with whitespace in the url get a 400 bad request error. Think the problem line of code is:

        proxy_pass http://127.0.0.1:3002$uri$is_args$query_string;

however not sure how to rewrite it.

This is how the site configuration at /etc/nginx/sites-available/default looks:

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;
     } 

0 Answers0