1

nginx access.log,

I want to do

status="200" access_log /var/log/access.log main;

status="444" access_log /var/log/access444.log main;

status="401" access_log /var/log/access401.log main;

this can be done?

Thnx

server { listen 5026; 
server_name wwwww;
    if ($allowed_country = no) {
return 444; }

if ($http_user_agent ~* "mozilla" ) {return 403; }
error_page   403 500 502 503 504  /50x.html;
location = /50x.html {
root   /usr/share/nginx/html;
}

location = / {
auth_basic            "Restricted"
auth_basic_user_file  /etc/nginx/users/password;
limit_conn peruser 2;
proxy_pass         http://localhost:9025;
proxy_redirect     off;
proxy_set_header   Host             $host;
proxy_set_header   X-Real-IP        $remote_addr;
proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
access_log  /var/log/access.log main;
}
}    
HopelessN00b
  • 53,795
  • 33
  • 135
  • 209

1 Answers1

1

You could try doing something like this:

error_page 401 /401.html;
error_page 444 /444.html;

location = /401.html {
    internal;
    access_log /var/log/nginx/401.log;
}

location = /444.html {
    internal;
    access_log /var/log/nginx/444.log;
}

More about error_page: http://nginx.org/en/docs/http/ngx_http_core_module.html#error_page

Nemke
  • 248
  • 5
  • 10