我在安装了Jenkins和Docker的机器上遇到了一些相当奇怪的行为。为了清楚起见,Jenkins并未作为Docker容器运行,而是在jenkins
用户下运行。为什么Docker主机上的Jenkins响应来自容器内部的HTTP请求?
当在容器中运行curl
,我得到一个403:
[email protected]:/# curl -I www.google.co.uk
HTTP/1.1 403 Forbidden
Date: Tue, 30 May 2017 13:41:07 GMT
X-Content-Type-Options: nosniff
Set-Cookie: JSESSIONID.f1223778=36hjq9sozhveoe1bfsss1dnq;Path=/;HttpOnly
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: text/html;charset=UTF-8
X-Hudson: 1.395
X-Jenkins: 2.46.3
X-Jenkins-Session: 2836b130
X-You-Are-Authenticated-As: anonymous
X-You-Are-In-Group-Disabled: JENKINS-39402: use -Dhudson.security.AccessDeniedException2.REPORT_GROUP_HEADERS=true or use /whoAmI to diagnose
X-Required-Permission: hudson.model.Hudson.Read
X-Permission-Implied-By: hudson.security.Permission.GenericRead
X-Permission-Implied-By: hudson.model.Hudson.Administer
Content-Length: 793
Server: Jetty(9.2.z-SNAPSHOT)
主机上的容器外,我得到预期的回应:
$ curl -I www.google.co.uk
HTTP/1.1 200 OK
Date: Tue, 30 May 2017 13:40:17 GMT
Expires: -1
Cache-Control: private, max-age=0
Content-Type: text/html; charset=ISO-8859-1
P3P: CP="This is not a P3P policy! See https://www.google.com/support/accounts/answer/151657?hl=en for more info."
Server: gws
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
Set-Cookie: NID=104=mMKjBy002X3N_SkhkD_8xuAwpFuw03CFi0iOJjNX81FUHfMT6qTq95LcgRwdhrV_GZoUF9LQ1B9qAQPriN9Er3Bu2JWoqPgvt16TduuVj5QsNs9GiJTQBtaSXWic7G9E; expires=Wed, 29-Nov-2017 13:40:17 GMT; path=/; domain=.google.co.uk; HttpOnly
Transfer-Encoding: chunked
Accept-Ranges: none
Vary: Accept-Encoding
詹金斯显然是责怪,但我我不知道为什么它会拦截离开容器的HTTP流量。 Ping谷歌工作正常,发送HTTPS请求也是如此。没有其他机器拥有这个问题(大概是因为他们没有安装Jenkins)。那么,这里发生了什么?我如何让Jenkins停止拦截来自Docker容器的HTTP?
更新
关闭詹金斯的‘防止跨站请求伪造攻击’选项使詹金斯不再返回403S。相反,Jenkins通过仪表板页面(即默认页面)响应来自容器内的任何HTTP请求。
另外值得注意的是,DNS工作正常;主机名解析为正确的IP地址。
我要走出Wireshark。