我在 10.251.130.45:8080 上运行jenkins服务器。 服务器在代理服务器后面。
然而这失败了。我使用ip和localhost作为jenkins实例的url进行了测试。它似乎全部转到代理。
如何让ansible仅通过代理运行基于DNS的查询?
以前我一直在使用:
environment:
http_proxy: http://webproxy.ec.local:9090
https_proxy: http://webproxy.ec.local:9090
并且只是将代理设置为“”以重置使用localhost地址的任务,但是,现在我需要同时使用localhost和远程url。 当然,我不想要代理的本地主机!
failed: [localhost] (item=authorize-project) => {
"details": "HTTP Error 502: cannotconnect",
"failed": true,
"invocation": {
"module_args": {
"attributes": null,
"backup": null,
"content": null,
"delimiter": null,
"directory_mode": null,
"follow": false,
"force": false,
"force_basic_auth": true,
"group": "jenkins",
"http_agent": "ansible-httpget",
"jenkins_home": "/var/lib/jenkins",
"mode": "0644",
"name": "authorize-project",
"owner": "jenkins",
"regexp": null,
"remote_src": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"src": null,
"state": "present",
"timeout": 500.0,
"unsafe_writes": null,
"updates_expiration": 86400,
"updates_url": "https://updates.jenkins-ci.org",
"url": "http://localhost:8080",
"url_password": "admin",
"url_username": "admin",
"use_proxy": true,
"validate_certs": true,
"version": null,
"with_dependencies": true
}
},
"item": "authorize-project",
"msg": "Cannot get CSRF"
使用curl的一些测试:
localhost调用给出了502就像ansible一样。
curl -X HEAD --proxy http://webproxy.ec.local:9090 -i localhost:8080 // 502
curl -X HEAD --proxy http://webproxy.ec.local:9090 -i 10.251.130.45:8080 // FAIL, timeout
curl -X HEAD -i http://10.251.130.45:8080 // 200 ok
答案 0 :(得分:0)
no_proxy env变量通过添加必要的例外来解决此问题。
environment:
http_proxy: http://webproxy.ec.local:9090
https_proxy: http://webproxy.ec.local:9090
no_proxy: 127.0.0.1, localhost, 10.251.*.*