小编car*_*ini的帖子

使用 Nginx 将子路径重定向到外部主机

我需要在 Nginx 中创建一个非常简单的映射,将子路径重定向到位于同一子网中的另一台服务器。

  • Nginx 服务器:192.168.0.2
  • Tomcat 服务器:192.168.0.3:8443

我试着把它放在服务器部分

    location /tomcatapi/ {
        rewrite /tomcatapi/(.*) $1 break;
        proxy_pass http://192.168.0.3:8443;
    }
Run Code Online (Sandbox Code Playgroud)

但是我访问http://www.myservice.com/tomcatapi/是一个 500 错误页面,在 nginx 日志文件中我有这个错误:

    the rewritten URI has a zero length
Run Code Online (Sandbox Code Playgroud)

我在这个 conf 中缺少什么?

nginx proxy reverse-proxy

19
推荐指数
1
解决办法
2万
查看次数

标签 统计

nginx ×1

proxy ×1

reverse-proxy ×1