我想在Docker容器中部署Jenkins。我将在与Jenkins相同的端口上使用其他软件部署其他其他容器。因此,我使用nginx作为反向代理,并在路径EXPORT DELIMITER table.field1 table.field2.
下公开Jenkins容器。
我的Docker撰写:
/jenkins
我的version: '3'
services:
reverseproxy:
build: reverseproxy
ports:
- "8080:80"
jenkins:
image: jenkins:2.60.3
volumes:
- "./storage/jenkins:/var/jenkins_home"
environment:
- JENKINS_OPTS="--prefix=/jenkins"
图片:
reverseproxy
我的FROM nginx:1.13.8-alpine
COPY nginx.conf /etc/nginx/nginx.conf
nginx.conf
Docker Compose靴子很好。我可以worker_processes 1;
events { worker_connections 1024; }
http {
sendfile on;
upstream docker-jenkins {
server jenkins:8080;
}
server {
listen 80;
location /jenkins/ {
proxy_pass http://docker-jenkins;
proxy_redirect off;
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-Host $server_name;
}
}
}
访问Jenkins。但是当我尝试登录或注销时,我被重定向到http://localhost:8080/jenkins
(通知端口消失了)。
这是http://localhost/jenkins/
输出:
curl
为什么我在没有端口的情况下被重定向到> curl -v localhost:8080/jenkins
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8080 (#0)
> GET /jenkins HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Server: nginx/1.13.8
< Date: Mon, 08 Jan 2018 14:03:15 GMT
< Content-Type: text/html
< Content-Length: 185
< Location: http://localhost/jenkins/
< Connection: keep-alive
<
? nginx配置有问题吗?