Mobile app version of vmapp.org
Login or Join
Angie530

: Nginx proxy_pass 404 error, don't understand why I'm trying to pass off all calls to /api to my webservice but I keep getting 404s with the following config. Calls to / return index.html as

@Angie530

Posted in: #Nginx

I'm trying to pass off all calls to /api to my webservice but I keep getting 404s with the following config. Calls to / return index.html as expected. Does anyone know why?

upstream backend{
server localhost:8080;
}

server {

location /api {
proxy_pass backend; }

location / {

root /html/dir;
}

}


More info here:

adept@HogWarts:/etc/nginx/sites-available$ curl -i localhost/api/authentication/check/user/email
HTTP/1.1 404 Not Found
Server: nginx/1.2.1
Date: Mon, 22 Apr 2013 22:49:03 GMT
Content-Length: 0
Connection: keep-alive

adept@HogWarts:/etc/nginx/sites-available$ curl -i localhost:8080/authentication/check/user/email
HTTP/1.1 200 OK
Content-Type: application/json
Date: Mon, 22 Apr 2013 22:49:20 GMT
Transfer-Encoding: chunked

{"user":["false"],"emailAddress":["false"]}

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Angie530

1 Comments

Sorted by latest first Latest Oldest Best

 

@Murray432

I think you're missing a slash in your proxy_pass, see nginx.org/r/proxy_pass.
It should be proxy_pass backend/;, if you want to map /api locationfrom Nginx to / from upstream, otherwise, it'll be going to /api on upstream, too.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme