我有一个具有以下位置和上游配置的nginx容器:
upstream jenkins-docker {
server jenkins:8080 fail_timeout=0;
}
# configuration file /etc/nginx/conf-files/jenkins-location.conf:
location /jenkins/ {
sendfile off;
proxy_pass http://jenkins-docker;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_max_temp_file_size 0;
#this is the maximum upload size
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_request_buffering off; # Required for HTTP CLI commands in Jenkins > 2.54
}詹金斯也在码头集装箱里。它们都连接到一个码头桥梁网络。在nginx容器里我可以:
curl jenkins:8080:
<html><head><meta http-equiv='refresh' content='1;url=/login?from=%2F'/><script>window.location.replace('/login?from=%2F');</script></head><body style='background-color:white; color:white;'>
Authentication required
<!--
You are authenticated as: anonymous
Groups that you are in:
Permission you need to have (but didn't): hudson.model.Hudson.Read
... which is implied by: hudson.security.Permission.GenericRead
... which is implied by: hudson.model.Hudson.Administer
-->
</body></html> 能和詹金斯沟通。
在jenkins -> manage ->配置系统中,在"Jenkins位置“下,我将"Jenkins”更改为http://myIP/jenkins
当我输入浏览器myIp/jenkins时,它被重定向到http://myIp/login?from=%2Fjenkins%2F,这将导致404
当我将nginx中的位置更改为"location /jenkins/ {“时,它就像一种魅力。这就是我为什么要重写它的原因:
rewrite ^/jenkins(.*) /$1 break;当我这样做时,我可以使用myIp/jenkis访问jenkins dashboar。但是当我点击菜单项时,我会得到404。
发布于 2018-03-15 19:04:22
您还需要在jenkins安装上设置--prefix命令。您可以在jenkins.xml配置文件中或通过修改命令行参数以包括--prefix=/jenkins来实现这一点。
这些参数可以在https://wiki.jenkins.io/display/JENKINS/Starting+and+Accessing+Jenkins上看到
发布于 2020-05-13 03:32:36
设置一个环境变量,如:JENKINS_OPTS="--prefix=/jenkins"。
如果您使用的是坞-构图,如下所示:
environment:
- JENKINS_OPTS="--prefix=/jenkins"https://stackoverflow.com/questions/49305287
复制相似问题