我想在Nginx后面运行datastax cassandra opscenter。 但它不断添加opscenter端口(默认8888)到所有的URL。 有没有configuration设置来禁用或什么?
这里是我的超级简单的nginxconfiguration:
server { server_name opscenter.hostname.com; location / { proxy_pass http://127.0.0.1:8888; } }
有什么我可能做错了吗?
通过添加nginxredirect到/ opscenter解决了这个问题
location = / { rewrite (.*) /opscenter; }
您需要创build如下所示的位置:
location / { proxy_pass http://127.0.0.1:8888; proxy_redirect http://localhost:8888/ /; proxy_redirect http://your.host.name:8888/ /; proxy_buffering off;
}
proxy_redirect行将从OpsCenter返回的响应中proxy_redirect 8888 。
有关proxy_redirect更多信息,请访问http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_redirect
我尝试了更多的build议configuration,但没有一个为我工作。
这是我的用例和我的解决scheme。
Nginx和OpsCenter都在两台不同的机器上。 与Nginx不同,OpsCenter不能直接从互联网访问。
Nginx的1.4.6是172.132.1.2 (公网)
OpsCenter 5.2.0在172.132.2.3 (专用networking)上
upstream opscenter { server 172.132.2.3:8888; } server { listen 81 default_server; listen [::]:81 default_server ipv6only=on; location / { proxy_pass http://opscenter; proxy_redirect http://$proxy_host:8888/ http://$host:$server_port/; proxy_buffering off; } location ~ /\.ht { deny all; } }