我在Nginx后面为Rundeck配置了反向代理。下面是Rundeck.conf,它位于路径/ 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 如下 LOGIN ----&GT; pilot1 / rundeck重定向到pilot1 / rundeck / menu / home(工作正常) 注销---&GT; PILOT1:4440 / rundeck /用户/ loggedout
我不想让端口暴露出来。我该如何解决这个问题?
答案 0 :(得分:4)
以下是我必须做的事情:
在适当的“服务器”部分下的NGINX配置中设置一个位置:
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 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