标签搜索

目 录CONTENT

文章目录

Docker+Nginx部署Jenkins

陈铭
2023-09-12 / 0 评论 / 0 点赞 / 88 阅读 / 236 字 / 正在检测是否收录...

Docker部署

docker run \
-u root \
-d \
-p 8380:8080 \
-p 53000:50000 \
-v /opt/jenkins/data:/var/jenkins_home \
-v /var/run/docker.sock:/var/run/docker.sock \
--name jenkins \
jenkinsci/blueocean

配置Ngx

proxy_set_header是必须的,这样JKS不会提示警告
之所以配置根目录映射jenkins是因为jenkins的访问主页也是http://127.0.0.1:8380,任何对https://<ip>/aa/bb都会映射到http://127.0.0.1:8380/aa/bb
如果在docker run配置了前缀--env JENKINS_OPTS="--prefix=/jenkins",此时ngx就可以配置成location /jenkins

vim /etc/nginx/conf.d/jenkins.conf

# 内容如下
server {
    listen 443;
    server_name <ip>;

    location / {
        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_set_header Host $host;
        proxy_pass http://127.0.0.1:8380;
    }
}

访问https://<ip>即可进入Jenkins

Jenkins插件国内源

进入https://<ip>/manage/pluginManager/advanced
配置清华镜像http://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json
image

0

评论区