B
B
bhavenger2013-10-11 07:01:07
Nginx
bhavenger, 2013-10-11 07:01:07

Logging hits to a specific url

There is a task to write access.log for a specific link. Selected it in a separate location - does not work.

location ^~ /blabla/ {
access_log /var/log/nginx/blabla_access.log;
root /etc/nginx/html/blabla;
try_files $uri @app;


Then I read somewhere that the log is written after all the handlers, so you need to write in @app. Copy- pasted @appinto @app1, tried the method - still does not work.

location @app1{
access_log /var/log/nginx/blabla_access.log;
access_log on;
limit_req zone=anticlick burst=5;
proxy_pass 127.0.0.1 :8080;
proxy_buffering on;
proxy_buffer_size 256k;
proxy_buffers 16 256k;
proxy_busy_buffers_size 512k;
proxy_redirect off;
proxy_next_upstream error timeout;
proxy_temp_path /var/tmp/nginx/tmp;
proxy_set_headerHost $host;
proxy_set_headerX-Real-IP "$remote_addr";
proxy_set_headerReferer>"$http_referer";
proxy_set_headerUser-Agent "$http_user_agent";
proxy_set_headerX-Forwarded-For "$proxy_add_x_forwarded_for";
proxy_set_headerHTTP_X_FORWARDED_FOR "$proxy_add_x_forwarded_for";
proxy_intercept_errors on;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bhavenger, 2013-10-11
@bhavenger

He asked, he answered.
The only working option was this one:
location ^~ /blabla{
access_log /var/log/nginx/blabla_access.log;
error_log /var/log/nginx/blabla_error.log;
root /etc/nginx/html/blabla;
proxy_passhttp://127.0.0.1:8080/blabla;
proxy_buffering on;
proxy_buffer_size 256k;
proxy_buffers 16 256k;
proxy_busy_buffers_size 512k;
proxy_redirect off;
proxy_next_upstream error timeout;
proxy_temp_path /var/tmp/nginx/tmp;
proxy_set_headerHost $host;
proxy_set_headerX-Real-IP "$remote_addr";
proxy_set_headerReferer "$http_referer";
proxy_set_headerUser-Agent "$http_user_agent";
proxy_set_headerX-Forwarded-For "$proxy_add_x_forwarded_for";
proxy_set_headerHTTP_X_FORWARDED_FOR "$proxy_add_x_forwarded_for";
proxy_intercept_errors on;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question