GET requests returning 404

sdenthumdas nginx-forum at nginx.us
Wed Feb 11 22:53:38 UTC 2015


Hi,

We are using Play for the backend and using NGinx to serve requests for
static files from local.

Below is the config that we are using 

upstream backend {
    server x.x.x.x:9000;
}

server {
    listen       0.0.0.0:8082;
    server_name localhost;

    location /client {
       root /static;
       expires off;
       sendfile  off;
    }
    
    location / {
      proxy_set_header Access-Control-Allow-Origin *;
      proxy_set_header 'Access-Control-Allow-Credentials' 'true';   
      proxy_set_header 'Access-Control-Allow-Headers'
'X-Requested-With,Accept,Content-Type, Origin';
      proxy_set_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS,
PUT, DELETE, HEAD';

      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_set_header X-NginX-Proxy true;

      proxy_pass http://backend;
      proxy_redirect off;
    }

}

Some requests like "GET /api/alerts" returns 404

Now here is the wierd part. When I update the configuration like below,
basically copying the same config for this specific uri path, I get 200 OK
back

upstream backend {
    server x.x.x.x:9000;
}

server {
    listen       0.0.0.0:8082;
    server_name localhost;

    location /client {
       root /static;
       expires off;
       sendfile  off;
    }
    
   location /api {
      proxy_set_header Access-Control-Allow-Origin *;
      proxy_set_header 'Access-Control-Allow-Credentials' 'true';   
      proxy_set_header 'Access-Control-Allow-Headers'
'X-Requested-With,Accept,Content-Type, Origin';
      proxy_set_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS,
PUT, DELETE, HEAD';

      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_set_header X-NginX-Proxy true;

      proxy_pass http://backend;
      proxy_redirect off;
    }

    location / {
      proxy_set_header Access-Control-Allow-Origin *;
      proxy_set_header 'Access-Control-Allow-Credentials' 'true';   
      proxy_set_header 'Access-Control-Allow-Headers'
'X-Requested-With,Accept,Content-Type, Origin';
      proxy_set_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS,
PUT, DELETE, HEAD';

      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_set_header X-NginX-Proxy true;

      proxy_pass http://backend;
      proxy_redirect off;
    }

}

what could be the issue?

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,256601,256601#msg-256601



More information about the nginx mailing list