【发布时间】:2017-03-24 10:55:52
【问题描述】:
我在 docker 中运行 nginx 来充当多个应用程序的反向代理。例如,
http://localhost/eureka/ will show http://registry:8761
http://localhost/zipkin/ will show http://zipkin:9411
我从以下 nginx conf 开始,
http {
server {
location /eureka/ {
proxy_pass http://registry:9761;
}
}
}
上面的配置不起作用,nginx抛出错误,
proxy | 172.20.0.1 - - [24/Mar/2017:10:46:28 +0000] "GET /eureka/ HTTP/1.1" 404 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.110 Safari/537.36"
但以下配置适用于显示尤里卡页面的http://localhost/。
http {
server {
location / {
proxy_pass http://registry:9761;
}
}
}
我错过了什么?根据nginx proxy_pass,它应该可以工作,但不是。
【问题讨论】:
-
两个位置不同,一个将URI
/eureka/传递给registry:9761,另一个传递/。在上游传递之前是否需要更改 URI? -
我想在nginx后面隐藏多个应用程序。如果在 URI 之后传递了某些内容,则必须传递它,例如/eureka/abc 必须传递给registry:9761/abc
标签: nginx docker nginx-location