如何根据子路径重定向 nginx?

如何根据子路径重定向 nginx?

我在同一个 Azure VM 上运行了 grafana 和 jenkins。对于 jenkins:http://localhost:8080 对于 grafana:http://localhost:3000

我想以这种方式设置 nginx。customdomain.com/grafana 应该转到 http://localhost:3000 customdomain.com/jenkins 或 customdomain.com 应该转到 http://localhost:8080

但即使 /grafana 也只适用于 jenkins。

如何修复?

nginx 中映射的默认配置文件。

 location /grafana {
                include /etc/nginx/proxy_params;
                proxy_pass          http://localhost:3000;
                proxy_read_timeout  60s;
        # Fix the "It appears that your reverse proxy set up is broken" error.
        # Make sure the domain name is correct
                #proxy_redirect      http://localhost:3000 https://customdomain.com;
        }

        location / {
                include /etc/nginx/proxy_params;
                proxy_pass          http://localhost:8080;
                proxy_read_timeout  60s;
        # Fix the "It appears that your reverse proxy set up is broken" error.
        # Make sure the domain name is correct
                proxy_redirect      http://localhost:8080 https://customdomain.com;
        }

相关内容