首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >nginx (码头)后面的Jenkins

nginx (码头)后面的Jenkins
EN

Stack Overflow用户
提问于 2018-03-15 17:03:56
回答 2查看 1.6K关注 0票数 0

我有一个具有以下位置和上游配置的nginx容器:

代码语言:javascript
复制
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:

代码语言:javascript
复制
<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/ {“时,它就像一种魅力。这就是我为什么要重写它的原因:

代码语言:javascript
复制
rewrite ^/jenkins(.*) /$1 break;

当我这样做时,我可以使用myIp/jenkis访问jenkins dashboar。但是当我点击菜单项时,我会得到404。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-03-15 19:04:22

您还需要在jenkins安装上设置--prefix命令。您可以在jenkins.xml配置文件中或通过修改命令行参数以包括--prefix=/jenkins来实现这一点。

这些参数可以在https://wiki.jenkins.io/display/JENKINS/Starting+and+Accessing+Jenkins上看到

票数 3
EN

Stack Overflow用户

发布于 2020-05-13 03:32:36

设置一个环境变量,如:JENKINS_OPTS="--prefix=/jenkins"

如果您使用的是坞-构图,如下所示:

代码语言:javascript
复制
environment:
  - JENKINS_OPTS="--prefix=/jenkins"
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49305287

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档