Hi, my problem is the following: I want to access Jenkins which I have running on my server through my browser at https://my-domain.com/jenkins
.
I have DO droplet with Ubuntu 16.04 which runs Nginx which works as a proxy server, forwarding all the traffic towards my Node.js application through https , which works fine when I visit my site at https://my-domain.com
.
I have successfully installed and run Jenkins (if I run a systemctl status jenkins
I can see that it's active), however I can't figure out, how my Nginx should be configured to access Jenkins properly.
What I tried to do is to set up a new location for it, but the result is that if I visit https://my-domain.com/jenkins
it redirects to https://my-domain.com/login?from=%2Fjenkins
and serves my Node.js application.
/etc/nginx/sites-enabled/default
) server {
listen 80;
listen [::]:80 default_server ipv6only=on;
return 301 https://$host$request_uri;
}
# HTTPS — proxy all requests to the Node app
server {
# Enable HTTP/2
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name my-domain.com;
# Access and error log for Jenkins
access_log /var/log/nginx/jenkins.access.log;
error_log /var/log/nginx/jenkins.error.log;
# Use the Let’s Encrypt certificates
ssl_certificate /etc/letsencrypt/live/my-domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/my-domain.com/privkey.pem;
# Include the SSL configuration from cipherli.st
include snippets/ssl-params.conf;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://localhost:5000/;
proxy_ssl_session_reuse off;
proxy_set_header Host $http_host;
proxy_cache_bypass $http_upgrade;
proxy_redirect off;
# Settings for Jenkins
# include /etc/nginx/proxy_params;
# proxy_pass http://localhost:8080;
# proxy_read_timeout 90s;
# proxy_redirect http://localhost:8080 https://my-domain.com;
}
location /jenkins {
include /etc/nginx/proxy_params;
proxy_pass http://localhost:8080;
proxy_read_timeout 90s;
}
}
Maybe the actual issue is not with the Nginx configuration but with Jenkins? Thanks in advance!
Ok, I have figured it out. I realized that instead of proxy_pass http://localhost:8080;
I had to use proxy_pass http://localhost:8080/jenkins/;
, and redirect to https with proxy_redirect http:// https://;
For further help please visit: https://wiki.jenkins.io/display/JENKINS/Jenkins+behind+an+NGinX+reverse+proxy
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.