Nginx 反向代理代理 求助

2016-10-26 21:42:21 +08:00
 qzf

upstream uplocal3{ server localhost:9800; }

server { listen 80; server_name www.hbjdzx.org.cn;

 location /{
          proxy_connect_timeout   3;
          proxy_send_timeout      30;
          proxy_read_timeout      30;
          proxy_pass  http://uplocal3/TrainHelper/site/;
        #  proxy_pass http://192.168.1.111:9800/TrainHelper/site/;
          proxy_set_header   REMOTE_ADDR  $remote_addr;
          proxy_set_header  Host  $host;
        }
}

直接访问 http://192.168.1.111:9800/TrainHelper/site/的话可以请求的到, 但配置 Nginx 反向代理就请求不到,求各位大神帮忙,看下配置有什么问题。

2888 次点击
所在节点    NGINX
6 条回复
whx20202
2016-10-26 21:46:00 +08:00
看一下 access_log ?
qzf
2016-10-26 21:49:48 +08:00
下面是请求 http://www.hbjdzx.org.cn/的日志
- [26/Oct/2016:13:08:26 +0000] - 192.168.1.104 GET / HTTP/1.1 - 192.168.1.111:9800 -GET / HTTP/1.1www.hbjdzx.org.cnups_resp_time: 0.016 request_time: 0.016
- [26/Oct/2016:13:24:07 +0000] - 192.168.1.104 GET / HTTP/1.1 - 127.0.0.1:9800 -GET / HTTP/1.1www.hbjdzx.org.cnups_resp_time: 0.344 request_time: 0.344
cheetah
2016-10-26 23:25:01 +08:00
感觉是 proxy_pass 的问题
liangmishi
2016-10-27 00:01:34 +08:00
proxy_pass http://192.168.1.111:9800;
qzf
2016-10-27 08:40:07 +08:00
proxy_pass http://192.168.1.111:9800;
这样可以代理到 Tomcat 下,但是后面的项目路径 /TrainHelper/site/ 要怎么加?
@liangmishi
liyvhg
2016-10-27 08:48:46 +08:00
@qzf proxy_pass http://localhost:8000/uri/;
参考资料: http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass

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

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

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

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

© 2021 V2EX