gpt4 book ai didi

docker - Jenkins在Nginx背后(Docker)

转载 作者:行者123 更新时间:2023-12-02 20:47:36 28 4
gpt4 key购买 nike

我有一个具有以下位置和上游配置的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
}

Jenkins也在docker容器中。它们都连接到docker bridge网络。在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>

Nginx可以与 Jenkins 交流。

在jenkins-> management Jenkins-> Configure System的“Jenkins位置”下,我将“Jenkins URL”更改为 http://myIP/jenkins

当我在浏览器中输入myIp / jenkins时,它将重定向到 http://myIp/login?from=%2Fjenkins%2F,结果为404

当我在nginx中将“location / jenkins / {”中的位置更改为“/”时,它就像一个 super 按钮。这就是为什么我尝试重写的原因:
rewrite ^/jenkins(.*) /$1 break;

当我这样做时,我可以使用myIp / jenkis访问jenkins仪表板。但是当我单击菜单项时,我得到了404

最佳答案

您还需要在jenkins安装上设置--prefix命令。您可以在jenkins.xml配置文件中或通过更改命令行参数以包括--prefix=/jenkins来执行此操作。

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

关于docker - Jenkins在Nginx背后(Docker),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49305287/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com