我正在使用https://github.com/jwilder/nginx-proxy进行nginx-proxy设置
端口80重定向正在运行。这意味着我可以使用test.example.com通过非SSL访问我的网站,但使用HTTPS我得到一个chrome错误“此网页不可用 ERR_CONNECTION_CLOSED“
然后我发现nginx-proxy的default.conf似乎不会监听443端口:
upstream docker-reverse-proxy.com {
## Can be connected with "test" network
# test_nginx_1
server 172.19.0.3:443;
}
server {
server_name docker-reverse-proxy.com;
listen 80 ;
access_log /var/log/nginx/access.log vhost;
location / {
proxy_pass https://docker-reverse-proxy.com;
}
}
以下是我的配置:
1)docker run -d -p 80:80 -p 443:443 -v /private/etc/ssl/certs:/etc/nginx/certs -v /var/run/docker.sock:/tmp/docker.sock:ro --name nginx-proxy --net=test jwilder/nginx-proxy:alpine
2)搬运工-compose.yml
version: '3'
services:
php-fpm:
build: .
restart: always
volumes:
- web:/www
networks:
- backend
nginx:
image: nginx:alpine
restart: always
environment:
- VIRTUAL_HOST=docker-reverse-proxy.com
- VIRTUAL_PROTO=https
- VIRTUAL_PORT=443
ports:
- 80
- 443
volumes:
- web:/www:ro
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
- /private/etc/ssl/certs:/etc/nginx/certs
networks:
- frontend
- backend
depends_on:
- php-fpm
volumes:
web:
networks:
backend:
frontend:
external:
name: test
答案 0 :(得分:0)
最后通过在nginx服务器环境下添加CERT_NAME来解决:
nginx:
image: nginx:alpine
restart: always
environment:
- VIRTUAL_HOST=docker-reverse-proxy.com
- VIRTUAL_PROTO=https
- VIRTUAL_PORT=443
- CERT_NAME=YOUR_CERT_NAME ## Add this