在nginx中设置jenkins的反向代理

1.修改nginx 的config文件,一般在/etc/nginx/nginx.conf,在server 中添加location

···
    location /jenkins{
       proxy_pass http://jenkins_ip:jenkins_port;
       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_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;
        # Required for new HTTP-based CLI
        proxy_http_version 1.1;
        proxy_request_buffering off;
        proxy_buffering off; # Required for HTTP-based CLI to work over SSL
   }
···

2.修改jenkins的配置文件,在centos系统中,位于/etc/sysconfig/jenkins,在
JENKINS_ARGS中追加prefix

···
JENKINS_ARGS="--prefix=/jenkins"
···
  1. 重启nginx ,重启jenkins
nginx -s reload
service jenkins restart
    原文作者:lewiswon
    原文地址: https://www.jianshu.com/p/8315657465ac
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞