我正在Docker容器内的生产服务器中运行各种应用程序。 可以说,我只想为运行在一个Docker容器中的jenkins服务器提供SSL / TSL安全性;要实现此目的,我使用了nginx-reverse-proxy和“让我们加密CA”。
要记住的要点:
nginx的docker-compose.yml:
version: '3'
services:
nginxserver:
image: nginx:latest
container_name: nginxserver
hostname: nginxserver
restart: always
ports:
- 8888:553
volumes:
- ./conf.d:/etc/nginx/conf.d
- dockervolumes/var/log/nginx/:/var/log/nginx/
- /path/to/letsencrypt/www.example.com/fullchain.pem:/etc/ssl/private/fullchain.pem
- /path/to/letsencrypt/www.example.com/privkey.pem:/etc/ssl/private/privkey.pem
networks:
- jen-network
external_links:
- 'jenkinsserver:jenkinsserver'
networks:
jen-network:
external : true
nginx.conf:
upstream jenkins {
server jenkinsserver:8080;
}
server {
listen 553 ssl default_server;
server_name www.exapmle.com;
error_log /var/log/nginx/error.log warn;
access_log /var/log/nginx/access.log main;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
#ssl
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ecdh_curve secp384r1;
ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384 OLD_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 OLD_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256";
ssl_prefer_server_ciphers on;
ssl_dhparam /etc/nginx/dhparam-4096.pem;
ssl_certificate /etc/ssl/private/fullchain.pem;
ssl_certificate_key /etc/ssl/private/privkey.pem;
ssl_session_timeout 10m;
ssl_session_cache shared:SSL:10m;
ssl_session_tickets off;
ssl_stapling on;
ssl_stapling_verify on;
location / {
proxy_pass http://jenkins;
proxy_redirect http://jenkins $scheme://example.com;
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;
}
面临的问题:
所有HTTP请求都重定向到HTTPS;由于 我无法查看在其他端口上运行的其他应用程序 (8888除外)在我的浏览器上。
例如:
http://www.example.com: 8888 重定向到http s ://www.example.com: 8888 ,我可以访问我的 jenkins用户界面。
但是http://www.example.com: 9090 也被重定向到http s ://www.example.com: 9090 ,但是我不想发生这种情况。
如果您提出解决方案,请告诉我。还要尝试在这里解释我在做什么错。