Skip to content

Instantly share code, notes, and snippets.

@wongyouth
Last active May 26, 2019 07:04
Show Gist options
  • Save wongyouth/9626ee86ccae63237d5cd89392fe01a2 to your computer and use it in GitHub Desktop.
Save wongyouth/9626ee86ccae63237d5cd89392fe01a2 to your computer and use it in GitHub Desktop.
docker-compose.yml of Jenkins with nginx as reverse proxy
version: '2'
services:
jenkins:
image: jenkinsci/blueocean
user: root
restart: always
volumes:
- jenkins-data:/var/jenkins_home
- /var/run/docker.sock:/var/run/docker.sock
- $HOME/jenkins:/home
nginx:
image: nginx:alpine
restart: always
depends_on:
- jenkins
ports:
- 80:80
- 443:443
volumes:
- ./jenkins.conf:/etc/nginx/conf.d/jenkins.conf
- nginx-log:/var/log/nginx
- $HOME/.ssl:/etc/nginx/ssl
volumes:
jenkins-data:
nginx-log:
server {
listen 80 default;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl default;
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
location / {
proxy_pass http://jenkins:8080;
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;
client_max_body_size 10m;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment