试验了几个反向代理,发现都面临一个问题

2016-10-28 17:35:35 +08:00
 iCodex

试验环境

主机: Mac 运行 Valte 跑 phpcms 程序,不加任何反代在本机或在内网内打开 phpcms.dev 进行任何操作都不会有问题的。

内网三台机器,全部最小化安装 ubuntu 14.04 lts , apt 直接安装各软件

配置都是直接拿官方教科书一般的配置文件,添加进去的配置少得可怜,连缓存都不会有的,不影响测试。

nginx 配置:

server {
  listen 80 default fastopen=256 reuseport;
  server_name _;
  access_log /var/log/nginx/proxy-access.log combined;
  error_log /var/log/nginx/proxy-error.log;

  resolver 8.8.4.4 8.8.8.8 valid=300s;
  resolver_timeout 10s;

  location / {
    proxy_pass http://172.16.1.168;
    include proxy.inc;
  }
}

varnish 配置: https://github.com/mattiasgeniar/varnish-4.0-configuration-templates/blob/master/default.vcl

squid 配置只是在原有默认配置上加了cache_peer上游服务器,访问其他都是没问题,唯独这个 phpcms 的安装步骤。

主要问题是在进行安装的第三步 post 数据时就一定过不去了,在 chrome 抓取到的错误信息如下:

156585: URL_REQUEST
http://phpcms.dev/install/install.php?
Start Time: 2016-10-28 17:19:10.326

t= 2381 [st=    0] +REQUEST_ALIVE  [dt=24547]
t= 2381 [st=    0]    DELEGATE_INFO  [dt=13]
                      --> delegate_info = "NavigationResourceThrottle"
t= 2394 [st=   13]   +URL_REQUEST_DELEGATE  [dt=2]
t= 2394 [st=   13]      DELEGATE_INFO  [dt=2]
                        --> delegate_info = "扩展程序“ uBlock Origin ”"
t= 2396 [st=   15]   -URL_REQUEST_DELEGATE
t= 2396 [st=   15]   +URL_REQUEST_START_JOB  [dt=24518]
                      --> load_flags = 37122 (BYPASS_CACHE | MAIN_FRAME | MAYBE_USER_GESTURE | VERIFY_EV_CERT)
                      --> method = "POST"
                      --> priority = "HIGHEST"
                      --> upload_id = "1477638942369727"
                      --> url = "http://phpcms.dev/install/install.php?"
t= 2396 [st=   15]      URL_REQUEST_DELEGATE  [dt=0]
t= 2396 [st=   15]      HTTP_CACHE_GET_BACKEND  [dt=0]
t= 2396 [st=   15]      HTTP_CACHE_DOOM_ENTRY  [dt=0]
                        --> net_error = -2 (ERR_FAILED)
t= 2396 [st=   15]      HTTP_CACHE_CREATE_ENTRY  [dt=0]
t= 2396 [st=   15]      HTTP_CACHE_ADD_TO_ENTRY  [dt=0]
t= 2397 [st=   16]     +HTTP_STREAM_REQUEST  [dt=6]
t= 2397 [st=   16]        HTTP_STREAM_REQUEST_STARTED_JOB
                          --> source_dependency = 156588 (HTTP_STREAM_JOB)
t= 2403 [st=   22]        HTTP_STREAM_REQUEST_BOUND_TO_JOB
                          --> source_dependency = 156588 (HTTP_STREAM_JOB)
t= 2403 [st=   22]     -HTTP_STREAM_REQUEST
t= 2403 [st=   22]     +UPLOAD_DATA_STREAM_INIT  [dt=0]
t= 2403 [st=   22]        UPLOAD_DATA_STREAM_INIT  [dt=0]
                          --> is_chunked = false
                          --> net_error = 0 (?)
                          --> total_size = 389
t= 2403 [st=   22]     -UPLOAD_DATA_STREAM_INIT
                        --> is_chunked = false
                        --> net_error = 0 (?)
                        --> total_size = 389
t= 2403 [st=   22]     +HTTP_TRANSACTION_SEND_REQUEST  [dt=1]
t= 2403 [st=   22]        HTTP_TRANSACTION_SEND_REQUEST_HEADERS
                          --> POST /install/install.php? HTTP/1.1
                              Host: phpcms.dev
                              Connection: keep-alive
                              Content-Length: 389
                              Pragma: no-cache
                              Cache-Control: no-cache
                              Origin: http://phpcms.dev
                              Upgrade-Insecure-Requests: 1
                              User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36
                              Content-Type: application/x-www-form-urlencoded
                              Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
                              DNT: 1
                              Referer: http://phpcms.dev/install/install.php?step=3
                              Accept-Encoding: gzip, deflate
                              Accept-Language: en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4,zh-TW;q=0.2,ja;q=0.2
t= 2403 [st=   22]        HTTP_TRANSACTION_SEND_REQUEST_BODY
                          --> did_merge = false
                          --> is_chunked = false
                          --> length = 389
t= 2403 [st=   22]       +UPLOAD_DATA_STREAM_READ  [dt=1]
                          --> current_position = 0
t= 2403 [st=   22]          UPLOAD_DATA_STREAM_READ  [dt=1]
                            --> current_position = 0
t= 2404 [st=   23]       -UPLOAD_DATA_STREAM_READ
t= 2404 [st=   23]        UPLOAD_DATA_STREAM_READ  [dt=0]
                          --> current_position = 389
t= 2404 [st=   23]     -HTTP_TRANSACTION_SEND_REQUEST
t= 2404 [st=   23]     +HTTP_TRANSACTION_READ_HEADERS  [dt=24510]
t= 2404 [st=   23]        HTTP_STREAM_PARSER_READ_HEADERS  [dt=24510]
                          --> net_error = -324 (ERR_EMPTY_RESPONSE)
t=26914 [st=24533]     -HTTP_TRANSACTION_READ_HEADERS
                        --> net_error = -324 (ERR_EMPTY_RESPONSE)
t=26914 [st=24533]   -URL_REQUEST_START_JOB
                      --> net_error = -324 (ERR_EMPTY_RESPONSE)
t=26926 [st=24545]    URL_REQUEST_DELEGATE  [dt=1]
t=26928 [st=24547] -REQUEST_ALIVE
                    --> net_error = -324 (ERR_EMPTY_RESPONSE)

看到最后的 HTTP_TRANSACTION_READ_HEADERS ,耗时 24510 ,然后网页就返回无响应被重置了。

6677 次点击
所在节点    问与答
8 条回复
vibbow
2016-10-28 19:33:59 +08:00
可以用 caddy 啊
billlee
2016-10-28 20:12:16 +08:00
proxy.inc 是什么内容?
iCodex
2016-10-28 23:30:31 +08:00
@billlee 就几行:

```
proxy_redirect off;
proxy_set_header Accept-Encoding '';
proxy_set_header Host $host;
proxy_set_header Referer $http_referer;
proxy_set_header Cookie $http_cookie;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
```
CRVV
2016-10-29 08:57:23 +08:00
谁教你设 fastopen=256 的?
iCodex
2016-10-29 12:16:59 +08:00
@CRVV 不加也不影响测试啊
iCodex
2016-10-29 12:20:26 +08:00
@CRVV 配置里还有个 SSL 监听的,后来没删除。可就是我删除了依然没法通过测试
binghe
2016-10-29 18:29:25 +08:00
请问这是什么字体???

iCodex
2016-10-29 23:35:58 +08:00
@binghe Monaco

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/316256

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX