【问题标题】:NGINX reverse proxy to a host with no root subdirectoryNGINX 反向代理到没有根子目录的主机
【发布时间】:2017-04-02 12:21:39
【问题描述】:

通常,在进行反向代理设置时,您的后端有一个服务器,如下所示:

http://localhost:8084/app-root

你可以代理_pass

location /app-root { proxy_pass http://localhost:8084; }

它将 www.my-domain.com/app-root 代理到内部服务器http://localhost:8084/app-root

太棒了!

如果服务器坚持从根目录托管,有人可以解释需要做什么:

http://localhost:8084/index.html http://localhost:8084/images/image1.jpg

我希望它可以通过

访问

http://www.my-domain.com/app/index.html
http://www.my-domain.com/app/images/image1.jpg

【问题讨论】:

    标签: nginx reverse-proxy


    【解决方案1】:

    您可以使用 nginx 的重写。像这样的东西应该可以工作

    location  /app/ {
      rewrite /app/(.*) /$1  break;
      proxy_pass         http://localhost:8084;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-08-21
      • 2018-04-11
      • 2019-12-22
      • 2018-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-12
      相关资源
      最近更新 更多