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 would like to enable access log in order to see statistics about our service, the problem I'm having is that the $request on the access logs format, saves all the GET parameters (which makes sense because its part of the request)

but I would like to hide this information, so instead of seeing this on the logs: - - [26/Apr/2014:23:59:09 +0000] "GET /v1/api.json?parameter1=value1&paramter2=value2" HTTP/1.1" 200 13449 "-" "httperf/0.9.0"

I would like to see - - [26/Apr/2014:23:59:09 +0000] "GET /v1/api.json" HTTP/1.1" 200 13449 "-" "httperf/0.9.0"
share|improve this question
Use POST requests. – Michael Hampton Apr 27 '14 at 0:01
Its not just for the benchmarking, our service should allow users to run search though GET requests, unfortunately that's not an option for me :( – rorra Apr 27 '14 at 0:11
up vote 5 down vote accepted

You can use log_format directive of ngx_http_log_module .

for example, this format would only show the uri without any query string:

http {
       log_format combined_no_query '$remote_addr - $remote_user [$time_local] '
           '"$uri" $status $body_bytes_sent '
           '"$http_referer" "$http_user_agent"';
       //other configs ...

 server {
       access_log /var/log/nginx/access.log combined_no_query

Notice the $uri variable which is used to log only the uri without any query string.

doc for log_format directive :

for more variables:

share|improve this answer
Thank you a lot, this was the solution I was looking for :) – rorra Apr 27 '14 at 3:26
Please note you are missing the request method (GET/POST etc.), so be sure to to include $request_method before $uri: '"$request_method $uri" $status $body_bytes_sent ' – cvaldemar Jun 18 '14 at 4:56

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.