Golang+Nginx实现日志打点
2022-04-12 本文已影响0人
Y了个J
准备nginx环境
修改nginx.conf然后 nginx -s reload
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 8080;
server_name localhost;
# 开启 access_log,后面解析这个日志文件,log_format 注释也打开
access_log logs/host.access.log main;
# 打点地址,单向流程不需要返回什么,empty_gif 只有200多B,很小
location /dig {
empty_gif;
# nginx不允许用POST方式请求静态资源,下面可以支持POST请求
error_page 405 =200 $request_uri;
}
......