V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
CCtry
V2EX  ›  问与答

一个 nginx 配置的问题

  •  
  •   CCtry · Nov 16, 2018 · 2150 views
    This topic created in 2727 days ago, the information mentioned may be changed or developed.

    家里的服务器上跑了几个服务,分别绑定在不同的端口。现在我想达到这种效果: 访问 www.example.com/portainer 转发到本机的 9000 端口, 看起来跟访问 www.example.com:9000 一个效果

    怎么写这种 nginx 配置?

    之前试着用 location 匹配,proxypass 转发,结果报了 502 错误。因为实际访问的是 www.example.com:9000/protainer

    4 replies    2018-11-16 18:45:21 +08:00
    mingshi044
        1
    mingshi044  
       Nov 16, 2018
    nginx upstream
    RemiliaForever
        2
    RemiliaForever  
       Nov 16, 2018
    newworld
        3
    newworld  
       Nov 16, 2018 via iPhone
    你的 location 加上 /portainer 再加上
    @RemiliaForever 的 proxypass
    newworld
        4
    newworld  
       Nov 16, 2018 via iPhone
    @newworld 如果是本地端口就 反代 127.0.0.1:9000
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   989 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 23:13 · PVG 07:13 · LAX 16:13 · JFK 19:13
    ♥ Do have faith in what you're doing.