我的 nginx 反向代理有问题。想要代理 (traefik. Traefik 在群中。它可以从 http://traefik.brt.local 访问。 (traefik 的标签)
现在在带有 nginx (serverNginx) 的服务器中,我已经指定了 /etc/hosts
#rpicluster - swarm
192.168.1.109 traefik.brt.local
192.168.1.109 helloworld.brt.local
现在我想在路径 /testowe 上使用 Traefik。尝试了下面的解决方案,但没有奏效。
location /testowe {
rewrite ^/testowe(.*) /$1 break;
proxy_pass http://traefik.brt.local;
}
如果我把所有东西都放在 / 上,那么一切都可以工作,但我不想放在根路径上。
location / {
proxy_pass http://traefik.brt.local;
}
在域上卷曲
curl -IL traefik.brt.local
HTTP/1.1 308 Permanent Redirect
Content-Length: 18
Content-Type: text/plain; charset=utf-8
Date: Fri, 05 Feb 2021 09:14:42 GMT
Location: http://traefik.brt.local/dashboard/
HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Length: 3026
Content-Type: text/html; charset=utf-8
Date: Fri, 05 Feb 2021 09:14:42 GMT
Last-Modified: Tue, 02 Feb 2021 17:20:37 GMT
在 localhost/testowe 上卷曲
curl -IL localhost/testowe
HTTP/1.1 308 Permanent Redirect
Server: nginx/1.14.2
Date: Fri, 05 Feb 2021 09:15:24 GMT
Content-Type: text/plain; charset=utf-8
Content-Length: 18
Location: http://localhost/dashboard/
Connection: keep-alive
HTTP/1.1 200 OK
Server: nginx/1.14.2
Date: Fri, 05 Feb 2021 09:15:24 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 3026
Connection: keep-alive
Accept-Ranges: bytes
Last-Modified: Tue, 02 Feb 2021 17:20:37 GMT
在本地主机上卷曲
curl -IL localhost
HTTP/1.1 308 Permanent Redirect
Server: nginx/1.14.2
Date: Fri, 05 Feb 2021 09:16:00 GMT
Content-Type: text/plain; charset=utf-8
Content-Length: 18
Location: http://localhost/dashboard/
Connection: keep-alive
HTTP/1.1 200 OK
Server: nginx/1.14.2
Date: Fri, 05 Feb 2021 09:16:00 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 3026
Connection: keep-alive
Accept-Ranges: bytes
Last-Modified: Tue, 02 Feb 2021 17:20:37 GMT