2

I configured my server with Nginx (v= ), and when I try to request using HEAD, I got a 404 :

curl -I http://postera.in

HTTP/1.1 404 Not Found
Server: nginx/1.2.1
Date: Thu, 19 Dec 2013 09:51:53 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 1900
Connection: keep-alive

Here's my server Nginx configuration :

server {
    listen       80;
    server_name  www.postera.in;
    return       301 $scheme://postera.in$request_uri;
}

server {
    listen       80;
    server_name  postera.in;
    access_log /var/log/nginx/postera_manager.access.log;
    error_log /var/log/nginx/postera_manager.error.log;

    location / {
        proxy_buffering    off;
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   X-Scheme $scheme;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   Host $http_host;
        proxy_pass  http://127.0.0.1:9800;
    }
}

What is wrong with this configuration ? Why a HEAD returns 404 instead of 200 ?

Thanks for the help :)

Cyril N.
  • 574
  • 1
  • 9
  • 33

3 Answers3

2

Well, I'll answer myself on that one.

The problem is not from NGinx but from the backend, here, PlayFramework that returns a 404 when a HEAD is requested and the routes files does not contains HEAD.

A bug has been opened for that : https://github.com/playframework/playframework/issues/2280

Cyril N.
  • 574
  • 1
  • 9
  • 33
0

what is the point to use:

return       301 $scheme://postera.in$request_uri;

and why not this one:

server_name www.example.com;
   rewrite ^ http://example.com$request_uri? permanent;

Also you can debug response directly from backed without nginx by the following command from command line on the server:

curl -I postera.in  --resolve  postera.in:9800:127.0.0.1 
Ilja
  • 432
  • 2
  • 9
-1

To troubleshoot such a problem, I would open two terminals on the Web server to trace your /var/log/nginx/postera_manager.access.log and /var/log/nginx/postera_manager.error.log along with running Wireshark on both ends (curl and Web server).

Also as the server responds to both http://postera.in AND http://www.postera.in I would give curl a try on both. As well I would also give wget a chance or any other Web crawler such as Lynx to eventually notice a difference. From the differences often come the root problem definition. From the very root cause, the solution comes up naturally.

I never suppose a root cause as long as not backed by observed facts, crossing as much as possible test conditions.

In the hope the above can help. Regards, Philippe Vouters (Fontainebleau/France [almost all career as software engineer support])