Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

curl -I

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;
    return       301 $scheme://$request_uri;

server {
    listen       80;
    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;

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

Thanks for the help :)

share|improve this question
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 :

share|improve this answer

what is the point to use:

return       301 $scheme://$request_uri;

and why not this one:

   rewrite ^$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  --resolve 
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 '14 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 AND 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. – Katherine Villyard Feb 1 '14 at 23:30

Your Answer


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.