我得到了nginx收到/解释的奇怪请求。
我在做什么......
在shell中发送请求:
$ echo -ne "GET / HTTP/1.1\r\nHost: localhost\r\n\r\n" | nc localhost 80
得到日志/var/log/nginx/access.log:
127.0.0.1 - - [23/Aug/2016:11:49:26 +0000] "@x\xEF\x01\xDCe\xCA\xB6t HTTP/1.1" "-" 400 172 "-" "-" "-"
不知何故,nginx将GET / HTTP/1.1\r\nHost: localhost\r\n\r\n
解释为@x\xEF\x01\xDCe\xCA\xB6t HTTP/1.1
。好像它改变了前几个字节。
ENV:
nginx.conf:
user nobody nogroup;
worker_processes 1;
error_log /var/log/nginx/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" "$request_uri" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
large_client_header_buffers 4 16k;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /www;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
strace的:
与此同时,我可以看到strace正确的请求recv(3, "GET / HTTP/1.1\r\nHost: localhost\r"..., 1024, 0) = 35
。
结论是:nginx或其配置有问题。
更新:开始使用新版本的简单解决方案;)