简体   繁体   English

詹金斯-403禁止

[英]Jenkins - 403 Forbidden

I just installed Jenkins on an Ubuntu 16.04-server via: 我刚刚通过以下方法在Ubuntu 16.04服务器上安装了Jenkins:

wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
echo "deb https://pkg.jenkins.io/debian-stable binary/" >> /etc/apt/sources.list
apt update
apt install jenkins

Afterwards I changed the port in /etc/default/jenkins to HTTP_PORT=8000 and added --httpPort=$HTTP_PORT --prefix=$PREFIX to the /etc/default/jenkins file and finally since I am running lots of stuff via apache already anyway I added a proxy there with: 之后,我将/etc/default/jenkins的端口更改为HTTP_PORT=8000 ,并将--httpPort=$HTTP_PORT --prefix=$PREFIX/etc/default/jenkins文件中,最后由于我通过apache运行了很多东西无论如何,我已经在其中添加了一个代理:

ProxyErrorOverride On
ProxyPass "/jenkins" "http://127.0.0.1:8000/jenkins/" 
ProxyPassReverse "/jenkins" "http://127.0.0.1/jenkins/" 

But when I try to access https://MY_URL/jenkins I get an 但是,当我尝试访问https://MY_URL/jenkins

Forbidden 禁止的

You don't have permission to access /jenkins on this server. 您无权访问此服务器上的/ jenkins。

But when I do curl localhost:8000 on the server I do seem to get the page. 但是,当我在服务器上curl localhost:8000时,我似乎得到了该页面。 So it seems to be running on that port at least, I just cannot access it via the apache (Other Proxies like /gitlab do work though the same way). 因此,它似乎至少在该端口上运行,我只是无法通过apache访问它(其他代理(如/ gitlab)也可以通过相同的方式工作)。

Does anyone have an idea what might be the problem here? 有谁知道这里可能是什么问题?

Edit: When I disable ProxyErrorOverride On I finally see the page where I can enter the admin password but doing so redirects me to the same page again: https://my_url/jenkins/login?from=%2Fjenkins%2F -> https://my_url/jenkins/login?from=%2Fjenkins%2F%2Fj_acegi_security_check . 编辑:当我禁用ProxyErrorOverride On我终于看到可以在其中输入管理员密码的页面,但这样做会将我再次重定向到同一页面: https://my_url/jenkins/login?from=%2Fjenkins%2F > https://my_url/jenkins/login?from=%2Fjenkins%2F%2Fj_acegi_security_check
So the current config for apache looks like this: 因此,Apache的当前配置如下所示:

## Proxy Settings
ProxyRequests          Off
ProxyPreserveHost      On
AllowEncodedSlashes    NoDecode
SetEnv                 proxy-nokeepalive 1
ProxyPass              "/gitlab"   "http://127.0.0.1:8001/gitlab/"
ProxyPassReverse       "/gitlab"   "http://127.0.0.1:8001/gitlab/"
ProxyPass              "/jenkins"  "http://127.0.0.1:8000/jenkins/" nocanon
ProxyPassReverse       "/jenkins"  "http://127.0.0.1:8000/jenkins/" 
ProxyPassReverse       "/jenkins"  "http://my_url/jenkins/"
RequestHeader          set X-Forwarded-Proto "https"
RequestHeader          set X-Forwarded-Port "443"

Alright I finally found the error: First ProxyErrorOverride On had to be removed and second I had to remove the trailing slash in the ProxyPass like this: 好吧,我终于找到了错误:必须删除第一个ProxyErrorOverride On ,然后第二个我必须删除ProxyPass中的结尾斜杠,如下所示:

ProxyPass              "/jenkins"  "http://127.0.0.1:8000/jenkins" nocanon
ProxyPassReverse       "/jenkins"  "http://127.0.0.1:8000/jenkins" 
ProxyPassReverse       "/jenkins"  "http://my_url/jenkins"

Interestingly gitlab did require it to work properly and jenkins does not work if the "/" are there. 有趣的是,gitlab确实要求它能够正常工作,并且如果存在“ /”,詹金斯将无法正常工作。

Maybe, the firewall blocks Jenkins 也许防火墙阻止了詹金斯

For me, simply run this command to resolve this issue 对我来说,只需运行此命令即可解决此问题

/etc/init.d/iptables.sh stop

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM