一、安装配置Jenkins

1.准备工作

  1. #安装JAVA
  2. yum install -y java

2.安装Jenkins

  1. #更换jenkins软件源仓库
  2. wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
  3. #导入密钥
  4. rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
  5. #yum安装jenkins
  6. yum install -y jenkins
  7. #查看jenkins安装的文件夹
  8. rpm -ql jenkins

3.修改配置

  1. vim /etc/sysconfig/jenkins
  2. #JENKINS_PORT="8080"
  3. #JENKINS_USER="root"

4.启动Jenkins服务

  1. systemctl start jenkins.service
  2. #开机自启
  3. systemctl enable jenkins.service
  4. systemctl status jenkins.service

浏览器访问对应端口,10.0.10.210:8080

二、Nginx域名转发

1.本地机Hosts清单

  1. vim /etc/hosts
  2. #添加一行10.0.10.210 myjenkins.com

2.远程机监听转发

  1. vim /etc/nginx/conf.d/jenkins.conf
  1. server {
  2. listen 80;
  3. server_name myjenkins.com;
  4. error_log /var/log/git.error.log ;
  5. client_max_body_size 60M;
  6. client_body_buffer_size 512k;
  7. location / {
  8. port_in_redirect on;
  9. proxy_pass http://127.0.0.1:8080$request_uri;
  10. proxy_redirect off;
  11. proxy_set_header Host $host;
  12. proxy_set_header X-Real-IP $remote_addr;
  13. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  14. }
  15. }
  1. #重启Nginx
  2. nginx -t
  3. nginx -s reload
  4. systemctl restart nginx