在 CentOS 上使用 Jenkins 配置代理(Proxy),通常有两种常见场景,我先说明,再给具体做法:
适用于:
localhost,127.0.0.1)适用于 yum / systemd 安装的 Jenkins
sudo vi /etc/sysconfig/jenkins
JENKINS_JAVA_OPTIONS="-Dhttp.proxyHost=proxy.example.com \
-Dhttp.proxyPort=8080 \
-Dhttps.proxyHost=proxy.example.com \
-Dhttps.proxyPort=8080 \
-Dhttp.nonProxyHosts=localhost|127.0.0.1"
sudo systemctl restart jenkins
git config --global http.proxy http://proxy:8080
git config --global https.proxy http://proxy:8080
settings.xml)<proxy>
<id>proxy</id>
<active>true</active>
<protocol>http</protocol>
<host>proxy.example.com</host>
<port>8080</port>
</proxy>
适用于:
server {
listen 80;
server_name jenkins.example.com;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
然后:
systemctl restart nginx
如果你能具体说明:
我可以给你更精确的配置示例。