Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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'm dealing with the following issue and I can't figure out to resolve it. I have HAproxy in front of app server farm which are running nginx. HAproxy has some httpchecks enabled for backend services - the checks are hitting /health_check URI:

option httpchk HEAD /health_check HTTP/1.1\r\nHost:\

What I can't figure out is how to avoid logging for Virtualhosts which have permanent rewrites enabled for all URIs. Here's the example

server {
  listen      8000;
  server_name "";

  location = /health_check {
    access_log off;
    return 200;

  rewrite     ^(.*)$1 permanent;

I thought the above location directive would disable the logs for given URI but I was wrong - it's being completely ignored.

is there any way how to acomplish something like this ??

share|improve this question
I wish I could accept 2 answers :-) – gyre Feb 26 '13 at 10:24
up vote 1 down vote accepted

Put the rewrite in a location / block.

location / {
    rewrite     ^(.*)$1 permanent;

This way, it will match all URLs except for /health_check which has a more specific location.

share|improve this answer

You could also return rather than rewrite using a location / block if you don't need the regex.

location / {
    return   301   $scheme://$request_uri;
share|improve this answer

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.