gpt4 book ai didi

java - 如何在NGINX反向代理后面运行 "Eclipse Che"?

转载 作者:行者123 更新时间:2023-11-30 10:50:30 26 4
gpt4 key购买 nike

我在服务器上安装了 Eclipse Che,当我在本地使用它时,它在我的机器上运行完美 localhost:8080

我想让它在 NGINX 前端反向代理之后从 Internet 上可用。这是想法:

example.com/che/ ---> NGINX 反向代理 ---> server:8080/

我尝试了很多不同的 NGINX 配置...都没有成功。有关信息,Eclipse Che 嵌入了一个具有一些重写规则的 Tomcat 实例:

RewriteRule ^/api/ext/(.*)$ /ide/ext/$1 [L]
RewriteRule ^/api/(.*)$ /ide/api/$1 [L]
RewriteRule ^/$ /dashboard [R]

Tomcat服务器上部署了3个webapps:

ide
dashboard
swagger

如果Eclipse Che在NGINX后面,上面的重写规则就没用了,可以直接由NGINX来完成(我就是这么做的)

我想在我的 NGINX 配置中有一个单独的 block (如果可能的话)这是我到目前为止尝试做的,但它没有完全工作并且 Eclipse Che 没有完全加载(我的猜测是 WebSockets 没有代理,我错过了一些东西)基本上,我尝试“代理传递”不同的网络应用程序,但这可能不是最佳选择。

location /dashboard {
proxy_pass http://localhost:8080/dashboard;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /ide {
proxy_pass http://localhost:8080/ide;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /api {
rewrite ^/api/ext/(.*)$ /ide/ext/$1 redirect;
rewrite ^/api/(.*)$ /ide/api/$1 redirect;
}

您会注意到我在 NGINX“api”位置而不是在 Tomcat 配置(ROOT webapp)中添加了重写规则感谢您的帮助。

最佳答案

仅供引用 http://nginx.org/en/docs/http/websocket.html

你必须添加一个 websocket 连接升级特定的 conf:

map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;

关于java - 如何在NGINX反向代理后面运行 "Eclipse Che"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35057344/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com