Iñaki Arango
Iñaki Arango

Reputation: 89

Routes other than "/" are not working running nginx

My Nginx configuration works fine only with the root location, all other locations return "Cannot GET {location}" where location is the rest of the address after the domain.

Here is my /etc/nginx/sites-enabled/default:

server {
    listen 80;

    server_name www.domain.net;

    location / {
        proxy_pass http://ip: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;
    }

    location /api/ {
        proxy_pass http://ip: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;
    }
}

To test I put the same ip in both locations, but only the root location works. How can I solve this?

Upvotes: 3

Views: 5287

Answers (1)

Farhad Farahi
Farhad Farahi

Reputation: 39277

Try the following:

proxy_pass http://ip:3000/;

Please note the trailing slash.

Upvotes: 3

Related Questions