docker-compose 简单搭建nginx的ssl环境
docker-compose 简单搭建nginx的ssl环境
说明:docker-compose实现nginx通过https访问,入门级示例
1、docker-compose.yml内容
version: "3" services: nginx: restart: always container_name: nginx image: nginx:1.16.0 ports: - 80:80 - 443:443 environment: TZ: Asia/Shanghai volumes: - ./nginx/conf.d:/etc/nginx/conf.d - ./nginx/log:/var/log/nginx - ./nginx/html:/usr/share/nginx/html - ./nginx/cert:/etc/nginx/cert - ./nginx/nginx.conf:/etc/nginx/nginx.conf
2、nginx.conf内容
server { listen 443 ssl http2; server_name _; root html; index index.html index.htm; ssl_certificate cert/******.pem; ssl_certificate_key cert/******.key; ssl_session_timeout 5m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; location / { root /usr/share/nginx/html; index index.html index.htm; } }