NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
qzf
V2EX  ›  NGINX

Nginx 反向代理代理 求助

  •  
  •   qzf · Oct 26, 2016 · 3827 views
    This topic created in 3523 days ago, the information mentioned may be changed or developed.

    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 反向代理就请求不到,求各位大神帮忙,看下配置有什么问题。

    6 replies    2016-10-27 08:48:46 +08:00
    whx20202
        1
    whx20202  
       Oct 26, 2016
    看一下 access_log ?
    qzf
        2
    qzf  
    OP
       Oct 26, 2016
    下面是请求 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
        3
    cheetah  
       Oct 26, 2016
    感觉是 proxy_pass 的问题
    liangmishi
        4
    liangmishi  
       Oct 27, 2016 via Android
    proxy_pass http://192.168.1.111:9800;
    qzf
        5
    qzf  
    OP
       Oct 27, 2016
    proxy_pass http://192.168.1.111:9800;
    这样可以代理到 Tomcat 下,但是后面的项目路径 /TrainHelper/site/ 要怎么加?
    @liangmishi
    liyvhg
        6
    liyvhg  
       Oct 27, 2016
    @qzf proxy_pass http://localhost:8000/uri/;
    参考资料: http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2564 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 08:37 · PVG 16:37 · LAX 01:37 · JFK 04:37
    ♥ Do have faith in what you're doing.