为Jenkins设置HTTPS的推荐方法是什么?
我们有一台虚拟机,其中Jenkins是唯一的应用程序。
答案 0 :(得分:2)
我使用的方法,我相信最简单的是使用nginx作为代理,示例配置:
root@redacted-jenkins-2:/etc/nginx/sites-available# cat jenkins_http.conf
#Ansible managed
server {
listen 80;
server_name jenkins.redacted.com.ar;
return 301 https://jenkins.redacted.com.ar$request_uri;
}
server {
listen 443 ssl;
server_name jenkins.redacted.com.ar;
ssl_certificate /etc/letsencrypt/live/jenkins.redacted.com.ar/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/jenkins.redacted.com.ar/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/jenkins.redacted.com.ar/fullchain.pem;
include /etc/nginx/snippets/ssl.conf;
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://127.0.0.1:8080;
}
}