Created
November 29, 2019 13:59
-
-
Save KamalakannanRM/2d9ee80be61e94310eef5c703b2ced0d to your computer and use it in GitHub Desktop.
Jenkins reverse proxy through Nginx with SSL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ssl_certificate /etc/nginx/ssl/jenkins.domain.tld/cert.pem; | |
ssl_certificate_key /etc/nginx/ssl/jenkins.domain.tld/privkey.pem; | |
upstream jenkins { | |
server 127.0.0.1:8080 fail_timeout=0; | |
} | |
server { | |
listen 80; | |
server_name jenkins.domain.tld; | |
return 301 https://$host$request_uri; | |
} | |
server { | |
listen 443 ssl; | |
server_name jenkins.domain.tld; | |
location / { | |
proxy_set_header Host $host:$server_port; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
proxy_redirect http:// https://; | |
proxy_pass http://jenkins; | |
# Required for new HTTP-based CLI | |
proxy_http_version 1.1; | |
proxy_request_buffering off; | |
proxy_buffering off; # Required for HTTP-based CLI to work over SSL | |
# workaround for https://issues.jenkins-ci.org/browse/JENKINS-45651 | |
add_header 'X-SSH-Endpoint' 'jenkins.domain.tld:50022' always; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment