FED

©FrontEndDev.org
2015 - 2024
web@2.23.0 api@2.21.1

nginx 反向代理 nodejs 程序,URL 被随机拦截

通过 nginx 反向代理 nodejs 程序,出现了随机部分 URL 被拦截的怪异现象,奇怪的是本站也是通过 nginx 反向代理的,但未发现此 BUG。所以说,这个 BUG 只对当前项目有效。

问题描述

代理访问

通过 nginx 反向代理访问(白色的浏览器日志,黑色的 node 日志,下同):

第1次

img.png

img.png

img.png

access.log

112.16.69.23 - - [21/Apr/2015:21:54:59 +0800] "GET /?url=1 HTTP/1.1" 200 450 "http://sb.com:18082/static/html/test.html" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36"
112.16.69.23 - - [21/Apr/2015:21:54:59 +0800] "GET /?url=2 HTTP/1.1" 200 450 "http://sb.com:18082/static/html/test.html" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36"
112.16.69.23 - - [21/Apr/2015:21:54:59 +0800] "GET /?url=7 HTTP/1.1" 200 450 "http://sb.com:18082/static/html/test.html" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36"
112.16.69.23 - - [21/Apr/2015:21:54:59 +0800] "GET /?url=8 HTTP/1.1" 200 450 "http://sb.com:18082/static/html/test.html" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36"

error.log

第2次

img.png

img.png

access.log:

112.16.69.23 - - [21/Apr/2015:21:55:54 +0800] "GET /?url=1 HTTP/1.1" 200 450 "http://sb.com:18082/static/html/test.html" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36"
112.16.69.23 - - [21/Apr/2015:21:55:54 +0800] "GET /?url=2 HTTP/1.1" 200 450 "http://sb.com:18082/static/html/test.html" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36"

error.log:

直接访问

直接 IP 地址访问:

img.png

img.png

域名解析

img.png

服务器 host

127.0.0.1 localhost
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.162.50.97 AY140601002820618982Z

本地 host

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1	localhost
127.0.0.1	sb.com
255.255.255.255	broadcasthost
::1	localhost
fe80::1%lo0	localhost


#xxxx
127.0.0.1	demo.xxxx.com
127.0.0.1	ceshi3038.xxxx.com
127.0.0.1	service.xxxxx.com
127.0.0.1	www.xxxx.com

nginx 配置

server{
 listen 80;
 server_name f.ydr.me;
 access_log /home/cloudcome/logs/f.ydr.me/access.log;
 error_log /home/cloudcome/logs/f.ydr.me/error.log;

 location / {
  proxy_pass_request_headers on;
  proxy_set_header Host $http_host;
  proxy_set_header X-Forwarded-For $remote_addr;
  proxy_pass http://127.0.0.1:18081;
  proxy_redirect off;
  client_max_body_size 10m;
 }
}

nginx 日志

  • access.log
  • error.log

node 程序

暂未发现 BUG。