ssl - 将letsencrypt ssl添加到 Jenkins 服务器

标签 ssl jenkins lets-encrypt certbot

我有一个 IP 地址为 ip.ip.ip.ip:8080 的 Jenkins 服务器。
目前它在 http 上运行,我需要在这里使用 certbot 添加 ssl。
我们可以将 SSL 添加到 ip 还是我应该为此需要一个子域或域名。
做过使用nginx反向代理的方法
遵循子域的 conf 文件

server {
     listen [::]:80;
     listen 80;

     server_name jenkins.thejus.cloudns.cl;

     return 301 https://jenkins.thejus.cloudns.cl$request_uri;
 }

 server {
     listen [::]:443 ssl;
     listen 443 ssl;

     server_name jenkins.thejus.cloudns.cl;

     ssl_certificate /etc/letsencrypt/live/jenkins.thejus.cloudns.cl/fullchain.pem;
     ssl_certificate_key /etc/letsencrypt/live/jenkins.thejus.cloudns.cl/privkey.pem;

     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_pass          http://127.0.0.1:8080;
         proxy_read_timeout  90;
         proxy_redirect      http://127.0.0.1:8080 https://jenkins.thejus.cloudns.cl;

         proxy_http_version 1.1;
         proxy_request_buffering off;
         add_header 'X-SSH-Endpoint' 'jenkins.thejus.cloudns.cl:50022' always;
     } 
 }
我在这里不需要服务器名称,而我只需要使用 ip.ip.ip.ip:8080 就可以访问 jenkins

最佳答案

您可以直接将 SSL 添加到 Jenkins 或在其前面放置一个 Nginx。
在这两种情况下,您都需要一个指向服务器 IP 的 DNS 条目和一个为该 DNS 条目生成的 letencrypt 证书。
对于 Nginx,配置文件可能如下所示:

server {
    listen 80;
    server_name build.mydomain.com;
    location /{
        proxy_set_header        X-Forwarded-For $remote_addr;
        proxy_set_header        Host $http_host;
        proxy_pass              "http://127.0.0.1:8080";
    }
}

server {
    listen 443 ssl http2 default_server;
    ssl on;
    server_name build.mydomain.com;
    ssl_certificate             /etc/ssl/certs/fullchain.cer;
    ssl_certificate_key         /etc/ssl/private/build.mydomain.com.key;
    ssl_trusted_certificate     /etc/ssl/certs/build.mydomain.com.cer;
    location /{
        proxy_set_header        X-Forwarded-For $remote_addr;
        proxy_set_header        Host $http_host;
        proxy_pass              "http://127.0.0.1:8080";
    }
}
当然,您需要确保将三个文件复制到引用的文件夹中:
/etc/ssl/certs/fullchain.cer
/etc/ssl/private/build.mydomain.com.key
/etc/ssl/certs/build.mydomain.com.cer
在这种情况下,我无法使重定向工作。

关于ssl - 将letsencrypt ssl添加到 Jenkins 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67417237/

相关文章:

ssl - 推荐的 OpenSSL 和密码学学习资源有哪些?

GitHub Services Jenkins 插件分支名称

jenkins - Jenkins 管道函数 fileExist 可以处理通配符吗?

ruby-on-rails - 让我们在同一个 DigitalOcean Droplet 上的 Node 和 Rails 应用程序上加密 SSL。适用于 Rails,但不适用于 Node

apache - Phabricator 通知服务器 SSL 错误

ssl - 代理服务和部署之间的 Kubernetes 自定义 CA 和证书

python - OpenSSL 要求私钥

firefox - Firefox 和 IE8 的 EV SSL 证书问题

jenkins - org.apache.maven.project.ProjectBuildingException : Some problems were encountered while processing the POMs: [ERROR] in WSO2 EI Project using jenkins

docker - Docker-compose + Nginx + Certbot +简单的Django Rest Framework应用