如何根據子路徑重新導向nginx?

如何根據子路徑重新導向nginx?

我有 grafana 和 jenkins 在同一個 azure 虛擬機器上運行。給詹金斯:http://localhost:8080 對於grafana:http://localhost:3000

我想到了這樣設定nginx。 customdomain.com/grafana 應該到 http://localhost:3000 customdomain.com/jenkins 或 customdomain.com 應該到 http://localhost:8080

但即使 /grafana 也只適用於詹金斯。

如何解決這個問題?

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;
        }

相關內容