Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

logging proxy activity in nginx

I am using rewrite and proxy_pass and I am having some intermittent issues with the site I am proxying said rewrites too. Is there a means to log the proxy activity so I that I can debug this problem?

like image 659
hinder90 Avatar asked Mar 28 '12 20:03

hinder90


People also ask

How do I get Nginx logs?

By default, the access log is located at /var/log/nginx/access. log , and the information is written to the log in the predefined combined format. You can override the default settings and change the format of logged messages by editing the NGINX configuration file ( /etc/nginx/nginx. conf by default).

How do I enable logging in Nginx?

Enabling the error log The NGINX error log should be enabled by default. However, if this is not the case, you can enable it manually in the relevant NGINX configuration file (either at the http , server , or location levels) using the error_log directive. error_log /var/log/nginx/error.

How do you check if Nginx reverse proxy is working?

To check the status of Nginx, run systemctl status nginx . This command generates some useful information. As this screenshot shows, Nginx is in active (running) status, and the process ID of the Nginx instance is 8539.


1 Answers

I am not an expert, but having the same problem here what I did in my nginx.conf :

log_format upstreamlog '[$time_local] $remote_addr - $remote_user - $server_name to: $upstream_addr: $request upstream_response_time $upstream_response_time msec $msec request_time $request_time';  access_log  /var/log/nginx/access.log upstreamlog; 

The first line define a new format, and then you tell access_log to use it

like image 115
mkx Avatar answered Sep 28 '22 02:09

mkx