Jenkins有时候就是容易抽筋,我在Tomcat配置了编码,就是不好使,我开始是因为nginx的反向代理的毛病,后来才发现,然后是tomcat作妖了,解决办法,就是拷贝我的tomcat配置,然后在我的基础上,添加参数,以及修改。

错误截图
这里写图片描述

1、配置nginx

Nginx配置好了后,需要配置nginx,设置https访问。

upstream  proxy_pool_jenkins {
        server 192.168.156.45:8080 weight=10;
    keepalive 512;
}

server
    {
        #listen 80;
            listen 443 ssl;
                    ssl_certificate      server.pem;
                    ssl_certificate_key  server.key;

                    ssl_session_cache    shared:SSL:1m;
                    ssl_session_timeout  5m;

                    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
                    ssl_ciphers  HIGH:!aNULL:!MD5;
                    ssl_prefer_server_ciphers  on;
            charset utf-8;  
                server_name jenkins.yellowcong.net;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /data/jeeroot/jenkins.yellowcong.net/ROOT;

        #error_page   404   /404.html;
        location / {
                        proxy_next_upstream error timeout http_500 http_502 http_503 http_504 http_404;
                        proxy_read_timeout 4s;

            proxy_http_version 1.1;
                        proxy_set_header Connection "";
                        proxy_connect_timeout 10;

            proxy_redirect off;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header Host $host;
                    #proxy_set_header X-Forwarded-For $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_pass http://proxy_pool_jenkins;
            #proxy_redirect http://proxy_pool_jenkins $scheme://jenkins.yellowcong.net;
            }
        location ~ ^/(WEB-INF)/ {
                deny all;
            }

        location /nginx_status {
            stub_status on;
            access_log   off;
        }

        location = /favicon.ico {
            log_not_found off;
            access_log off;
        }
        location = /robots.txt {
            log_not_found off;
            access_log off;
        }

        location ~/\. {
            deny all;
            access_log off;
            log_not_found off;
        }

            location ~ /\.(ht|svn|git) {
                    deny all;
            }

        access_log  /home/wwwlogs/jenkins.yellowcong.net.log  access;
    }
server {
        listen 80;
        server_name jenkins.yellowcong.net;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /data/wwwroot/jira.yellowcong.net/;
        return 301 https://$server_name$request_uri;
}

2、配置tomcat

配置tomcat目录下conf/server.xml 配置,下面的直接拷贝,如果不直接拷贝,可能你的编码会有问题,最好是在我的基础上,添加参数

 <Connector port="8080" protocol="HTTP/1.1"
            connectionTimeout="20000"
            URIEncoding="UTF-8"
            redirectPort="8443"
            proxyName="jenkins.yellowcong.net" 
            scheme="https" 
            proxyPort="443" />

重启tomcat后,那个讨人厌的错误终于么有了。
这里写图片描述

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐