问题描述
我已经为 Nginx 后面的 Rundeck 配置了反向代理.下面是Rundeck.conf,它放在路径/etc/nginx/sites-enabled
I have configured reverse proxy for Rundeck behind Nginx. Below is the Rundeck.conf which is placed in the path /etc/nginx/sites-enabled
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
ssl_session_cache shared:SSL:1m;
ssl_prefer_server_ciphers on;
## server configuration
server {
listen 443 ssl;
listen 80 ;
server_name ~(?<repo>.+)\.pilot1 pilot1;
if ($http_x_forwarded_proto = '') {
set $http_x_forwarded_proto $scheme;
}
## Application specific logs
## access_log /var/log/nginx/pilot1.ci1.peapod.com-access.log timing;
## error_log /var/log/nginx/pilot1.ci1.peapod.com-error.log;
# rewrite ^/$ /rundeck/menu/home redirect;
rewrite ^/rundeck/?(/rundeck)?$ /rundeck/menu/home redirect;
chunked_transfer_encoding on;
client_max_body_size 0;
location ^~ /rundeck/ {
proxy_pass http://localhost:4440;
proxy_read_timeout 900;
}
}
当我浏览并登录到 Rundeck 时,反向代理工作正常.但是当我单击注销时,重定向到登录页面会暴露端口:4440如下登录---->pilot1/rundeck 重定向到pilot1/rundeck/menu/home(工作正常)注销--->pilot1:4440/rundeck/user/loggedout
Reverse proxy works fine when I browse and login to Rundeck.But when I click log out the redirection to the login page exposes the port:4440as belowLOGIN----> pilot1/rundeck redirects to pilot1/rundeck/menu/home (works fine)Logout---> pilot1:4440/rundeck/user/loggedout
我不想暴露端口.我该如何解决这个问题?
I do not want the port to be exposed. How do i fix this issue?
推荐答案
这是我必须做的:
在适当的服务器"部分下的 NGINX 配置中设置一个位置:
In NGINX config under an appropriate 'server' section set up a location:
location /rundeck/ {
proxy_pass http://localhost:4440;
proxy_set_header X-Forwarded-Host $host:$server_port;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
Rundeck 配置:
Rundeck config:
sed -i "/^grails.serverURL/c grails.serverURL = ${RUNDECK_URL}" /etc/rundeck/rundeck-config.properties
sed -i "/^framework.server.url/c framework.server.url = ${RUNDECK_URL}" /etc/rundeck/framework.properties
sed -i '/^RDECK_JVM="$RDECK_JVM/ s/"$/ -Dserver.web.context=\/rundeck"/' /etc/rundeck/profile
RUNDECK_URL
应该指向你的 NGINX ip(dns 名称)所以 http://my-nginx.com/rundeck
where RUNDECK_URL
should point to you NGINX ip (dns name) so http://my-nginx.com/rundeck
这篇关于Nginx 背后的 Rundeck 反向代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!