load_module '/usr/lib64/nginx/modules/ngx_stream_module.so';
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
stream {
log_format basic '$remote_addr [$time_local] '
'$protocol $status $bytes_sent $bytes_received '
'$session_time';
access_log /var/log/nginx/access.log basic;
server {
listen 80;
proxy_pass web.server.com:80;
}
server {
listen 443;
proxy_pass web.server.com:443;
}
}
i通过Chrome开放了我本地笔记本电脑的网站,它打开了良好的打开,Chrome DevTool在
Headers tab > General > Remote Address field
sudo tcpdump -nn -A -s1500 -l -i eth0 port 443
(from tcpdump)
23:51:46.944945 IP user_ip.27149 > proxy_ip: length 357
23:51:46.945040 IP proxy_ip.44488 > webserver_ip.443: length 357
23:51:47.026161 IP webserver_ip.443 > proxy_ip.44488: length 364
23:51:47.026245 IP proxy_ip.443 > user_ip.27149: length 364
但是当我在代理服务器中打开访问日志文件时,没有条目。 conlike stackoverflow中的类似问题
nginx访问日志条目在发生时不会为某些连接创建,没有初始条目。只是空
I首先可疑Access_log配置,但是当我从笔记本电脑上卷曲相同的URL时,条目突然出现在Access_log文件中。每次我卷曲URL时都会出现。
user_ip [15/Feb/2021:23:21:25 +0000] TCP 200 1291080 3279 356.730
user_ip [15/Feb/2021:23:28:24 +0000] TCP 200 215 568 119.923
user_ip [15/Feb/2021:23:33:24 +0000] TCP 200 5646 643 300.140
我不确定为什么只将卷曲请求登录到access_log文件中。 😢所有请求都是在HTTPS协议上提出的。
将问题移交给了ServerFault.https://serverfault.com/questions/1053914/1053914/access-to-nginx-stream-proxy-is-inot-not-logged-in-access-log-file
我也有类似的问题。对我来说,麻烦是只有在连接关闭时才记录下来。将HTTP请求标头设置为
Connection
为我解决了问题。对于浏览器的提取重新要求无法做到这一点,因此无法解决OP的问题,我只是想评论以防万一可能会对其他人有所帮助。