使用nginx反向代理解决jenkins插件更新慢问题
2020-03-05 12:00
946 查看
本文参考链接https://my.oschina.net/VASKS/blog/3106314
具体原理及说明请参考原文。
由于本人纯新手因此详细记录操作过程,便于以后查阅。
系统环境如下:
操作系统:ubuntu 18.04
jenkins版本:2.222
修改hosts文件添加内容如下
127.0.2.1 updates.jenkins-ci.org ## Google为网络连通性测试地址,由于本人网络无法访问,因此也反向代理到百度 127.0.2.2 www.google.com
安装nginx
sudo apt-get install nginx
配置nginx反向代理
- 新增配置文件 /etc/nginx/sites-enabled/updates.jenkins-ci.org.conf
jenkins的default.json中要访问updates.jenkins-ci.org/download/xxxxx,把updates.jenkins-ci.org/download替换为mirrors.tuna.tsinghua.edu.cn/jenkins
使用 “location ^~ /download/” 来控制这个子页面的访问
内容如下:
server { listen 80; server_name updates.jenkins-ci.org; location / { proxy_redirect off; proxy_pass https://mirrors.tuna.tsinghua.edu.cn/jenkins; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Accept-Encoding ""; #proxy_set_header User-Agent "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.49 Safari/537.36"; proxy_set_header Accept-Language "zh-CN"; } location ^~ /download/ { proxy_pass https://mirrors.tuna.tsinghua.edu.cn/jenkins/; } index index.html index.htm index.php; #error_page 404 /404.html; location ~ /\. { deny all; } access_log /var/log/nginx/mirrors.access.log; error_log /var/log/nginx/mirrors.error.log; }
- 新增配置文件 /etc/nginx/sites-enabled/google.com.conf
内容如下:
server { listen 80; server_name www.google.com; location / { proxy_redirect off; proxy_pass https://www.baidu.com/; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Accept-Encoding ""; #proxy_set_header User-Agent "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.49 Safari/537.36"; proxy_set_header Accept-Language "zh-CN"; } index index.html index.htm index.php; #error_page 404 /404.html; location ~ /\. { deny all; } access_log /var/log/nginx/google.access.log; error_log /var/log/nginx/google.error.log; }
然后重启nginx服务就可以了
service nginx restart
- 点赞
- 收藏
- 分享
- 文章举报
相关文章推荐
- 解决Sublime There are no packages available for installation无法使用Package Control更新插件的问题
- 解决Access数据库中"操作必须使用一个可更新的查询"问题
- asp.net mvc使用的心得和问题的解决方法(陆续更新ing)
- 解决Eclipse更新ADT插件时遇到的Eclipse reports rendering library more recent than ADT plug-in问题
- 关于ASP.NET“操作必须使用一个可更新的查询”问题的解决方法
- 使用eclipse+git插件开发android项目时遇到的问题及解决
- Linux--14:ubuntu12.04 vi不能正常使用、右上角出现红杠提醒更新出问题、网速比相同条件下windows下慢 解决方法
- 使用Ubuntu遇到的问题以及解决方法(持续更新)
- 终于解决了eclipse的metrics插件使用一段时间后就无法使用的问题
- 使用jrebel插件解决修改项目中的class导致server重启问题-----for resin server
- Asp.net生成Excel文件并下载(更新:解决使用迅雷下载页面而不是文件的问题)
- QT Creator 使用 design 修改 ui界面编译后界面未更新问题的解决 From EricQu
- SDK Manager更新adt sdk包后Eclipse无法使用的问题及其解决办法
- iOS开发之使用CocoaPods更新第三方出现“target overrides the `OTHER_LDFLAGS`……”问题解决方案
- 什么是CocoaPods?安装CocoaPods,使用CocoaPods安装第三方库,更新CocoaPods本身,解决安装第三方库失败问题
- netbeans使用问题汇总于解决(不定期更新)
- ASP.Net下如何解决关于Access数据库“操作必须使用一个可更新的查询”问题
- maven eclipse插件使用问题解决
- 【原】Asp.net生成Excel文件并下载(更新:解决使用迅雷下载页面而不是文件的问题)
- Maven使用Proguard插件时遇到内存溢出问题解决