从foo.website.com到localhost的proxy_pass:在docker上使用nginx的xxxx – 在物理机器上不是localhost

我正在尝试让foo.website.com显示localhost:8181和bar.website.com上显示localhost:3000的内容。 不过,我希望它从泊坞窗盒(其中:8181和:3000显示我想要的)显示本地主机,而不是我的物理机上的本地主机(它们是空白的 – 没有使用)。我使用nginx做到这一点,而nginx的configuration是在我的docker文件。

Gaphite运行在localhost:3000上,graphics浏览器(更好看/标签支持石墨前端)是在localhost:8181 – 都可以正常工作,当我把url直接到我的浏览器。 Graphite的manage.py在localhost:8080上运行,这就是为什么graphics浏览器处于打开状态:8181。

这是我在这里的第一篇文章,我是新来的docker / nginx和networking一般,所以如果我错过信息/不清楚,我会很乐意纠正…

nginx settings: server { listen 80; root /opt/graphite/webapp/content; index index.html; location / { # checks for static file, if not found proxy to app try_files \$uri @app; } # The location is where I'm trying to go from location foo.website.com { # This is the port graph-explorer is running on proxy_pass 127.0.0.1:8181; } location @app { include fastcgi_params; fastcgi_split_path_info ^()(.*)$; fastcgi_pass 127.0.0.1:8080; } server_name website.com; } 

在我的主机文件(在docker机和虚拟箱docker运行在 – 不知道我是否应该都有?)

 127.0.0.1 foo.website.com 127.0.0.1 bar.website.com 

值得注意的是,这大部分是由我在网上find的东西拼凑而成,所以如果有什么可疑的话,答案可能就是“马修是白痴”。

非常感谢:) M

如果我理解正确,你想要:

foo.website.com代理传递给localhost:8181
bar.website.com代理传递给localhost:3000

尝试这个:

 server { listen 80; server_name foo.website.com; # foo.website.com proxy pass to localhost:8181 location / { proxy_pass http://127.0.0.1:8181; proxy_set_header Host $host; } } server { listen 80; server_name bar.website.com; # bar.website.com proxy pass to localhost:3000 location / { proxy_pass http://127.0.0.1:3000; proxy_set_header Host $host; } }