目录

Nginx反向代理jenkins

目录

参考文献 :

https://wiki.jenkins.io/display/JENKINS/Jenkins+behind+an+NGinX+reverse+proxy

以下为个人解决方案 :
jenkins 配置:

  • 添加启动参数 --prefix=/jenkinsdocker启动添加环境变量JENKINS_OPTS="--prefix=/jenkins"
  • 前端修改(Jenkins > Manage Jenkins > Jenkins Location > Jenkins URL) 或者修改配置文件/var/jenkins_home/jenkins.model.JenkinsLocationConfiguration.xml中的jenkinsUrl,修改为http(s)://www.example.com/jenkins/,配置文件修改后需重启。

nginx配置:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
    location /jenkins {
 
        proxy_pass http://10.0.0.100:8080/;
         
        proxy_redirect http:// https://;
 
        sendfile off;
 
        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_max_temp_file_size 0;
 
        # This is the maximum upload size
        client_max_body_size       10m;
        client_body_buffer_size    128k;
 
        proxy_connect_timeout      90;
        proxy_send_timeout         90;
        proxy_read_timeout         90;
 
        proxy_temp_file_write_size 64k;
  
        proxy_http_version 1.1;
        proxy_request_buffering off;
        proxy_buffering off;
  }