I am trying to run Jenkins behind nginx. Jenkins runs in a Docker container, listening on Port 8080 from directory /jenkins. My nginx container has this Jenkins container linked as hostname "jenkins", so in its context, Jenkins is accessible via http://jenkins:8080/jenkins.
I followed the steps at Running Jenkins from a folder with TLS encryption and thus my site-config
contains this:
location ^~ /jenkins/ {
sendfile 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;
proxy_pass http://jenkins:8080/jenkins/;
proxy_redirect http:// https://;
proxy_max_temp_file_size 0;
client_max_body_size 64m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
I am now trying to access the nginx from localhost, and calling https://localhost/jenkins presents me Jenkins. However, when I go to "Manage Jenkins", I get the message that my reverse proxy setup is incorrect. I tried
curl -k -iL -e https://localhost/jenkins/manage \
https://localhost/jenkins/administrativeMonitor/hudson.diagnosis.ReverseProxySetupMonitor/test
which gives me a 404 with http://localhost/jenkins/manage vs. https:
.
When I add
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-Port 443;
proxy_set_header X-Forwarded-Ssl on;
the message changes to https://localhost/jenkins/manage vs. https:
What am I missing?
curl
do you get a value for theLocation:
response header? This might help you add a more specificproxy_redirect
parameter.curl -vvv -k -iL -e https://localhost/jenkins/manage https://localhost/jenkins/administrativeMonitor/hudson.diagnosis.ReverseProxySetupMonitor/test 2>&1 |grep Location
gives me:< Location: https://localhost/jenkins/administrativeMonitor/hudson.diagnosis.ReverseProxySetupMonitor/testForReverseProxySetup/https%3A%2F%2Flocalhost%2Fjenkins%2Fmanage/ Location: https://localhost/jenkins/administrativeMonitor/hudson.diagnosis.ReverseProxySetupMonitor/testForReverseProxySetup/https%3A%2F%2Flocalhost%2Fjenkins%2Fmanage/
- what does this tell me?proxy_redirect
seems to be functioning correctly.curl -k -iL -e https://localhost/jenkins/manage https://localhost/jenkins/administrativeMonitor/hudson.diagnosis.ReverseProxySetupMonitor/testForReverseProxySetup/a
I gethttps://localhost/jenkins/manage vs. a
, however, with.../testForReverseProxySetup/a/b
, I also get... vs a
. Same with...a%2Fb
. Any ideas?curl
on my other internal Jenkins which only listens on http, I get the same 404, but I have been running it for over a year without any problems now.