Reputation: 89
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
Reputation: 39277
Try the following:
proxy_pass http://ip:3000/;
Please note the trailing slash.
Upvotes: 3