Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 :)

share|improve this question

3 Answers 3

up vote 1 down vote accepted

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

share|improve this answer

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 
share|improve this answer
    
Because return is faster. If you don't actually need to match a regex, there's no point to use rewrite. –  Michael Hampton Feb 2 at 0:18

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])

share|improve this answer
    
It's encouraged to "name" your user account rather than using a signature. serverfault.com/help/behavior –  Katherine Villyard Feb 1 at 23:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.