【发布时间】:2020-04-09 17:55:23
【问题描述】:
我有 jenkins 和 nginx 通过 docker-compose 运行,它们都在同一个 docker 网络上。 Jenkins 不向主机公开任何端口,其默认配置为在端口 8080 上运行,nginx 映射 8003:443。
我们有一个位于专用网络和子域上的服务器,我有以下 nginx 配置文件
upstream jenkins {
server jenkins:8080;
}
server {
listen 443 ssl;
server_name abc.example.com;
ssl_certificate /etc/ssl/private/certificate.crt;
ssl_certificate_key /etc/ssl/private/key.pem;
root /var/run/jenkins/war/;
ignore_invalid_headers off; #pass through headers from Jenkins which are considered invalid by Nginx server.
location ~ "^/static/[0-9a-fA-F]{8}\/(.*)$" {
#rewrite all static files into requests to the root
#E.g /static/12345678/css/something.css will become /css/something.css
rewrite "^/static/[0-9a-fA-F]{8}\/(.*)" /$1 last;
}
location /userContent {
#have nginx handle all the static requests to the userContent folder files
#note : This is the $JENKINS_HOME dir
root /var/lib/jenkins/;
if (!-f $request_filename){
#this file does not exist, might be a directory or a /**view** url
rewrite (.*) /$1 last;
break;
}
sendfile on;
}
location / {
proxy_pass http://jenkins/;
proxy_buffering off;
proxy_set_header X-Real-IP $remote_addr;
sendfile off;
proxy_redirect default;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port 443;
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_set_header Connection ""; # Clear for keepalive
}
}
这些设置中的大部分都来自故障排除指南,因为我最初的尝试没有将它们全部列出,我曾经并且仍然收到通知It appears that your reverse proxy set up is broken. 目前,它似乎只是部分工作。一些 url 可以正常工作,比如如果我点击人,我会得到https://abc.example.com:8003/asynchPeople/,但其他的比如登录和蓝海似乎放弃了端口。手动添加这个确实会使 url 然后工作。所以我不确定到底出了什么问题。我还应该补充一下,我已将 jenkins url 设置为 abc.example.com:8003
【问题讨论】:
标签: docker nginx jenkins reverse-proxy