I have the following basic Nginx configuration that proxies requests through to my Go app, which runs on port 8080:
server {
listen 80 default_server;
listen [::]:80 default_server;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
server_name 192.168.50.50;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8080;
}
}
I came across this configuration by doing some googling, however it doesn't seem to be logging any access or errors. Am I doing something wrong?
评论:
the_jester:
mrfrobozz:Your question has essentially nothing to do with Go, and is better restated: "What are the logging capabilities of Nginx?".
The answer is - Nginx can log just fine, but keep in mind its "error log" and "access log" are for its errors and access, not errors that may occur within your go code.
See the basic on Nginx logging here.
nicklaw5:You should be letting nginx log it's errors and have your go app logging it's own errors to its own log files.
It seems to be working fine now. Thanks.
