大致与这篇博文相同
附上自己的配置
nginx容器启动命令,cert文件夹也要挂载,其中是ssl的两个文件
docker run -d -p 80:80 -p 443:443 --name mynginx
-v /home/docker/nginx/conf/nginx.conf:/etc/nginx/nginx.conf
-v /home/docker/nginx/log:/var/log/nginx
-v /home/docker/nginx/html:/usr/share/nginx/html
-v /home/docker/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf
-v /home/docker/nginx/cert:/etc/nginx/cert
nginx
nginx.conf文件不动
default.conf
server {
listen 80;
server_name lande.xyz www.lande.xyz;
rewrite ^(.*)$ https://$host$1 permanent;
location / {
root /usr/share/nginx/html/edu;
try_files $uri /index.html
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
server {
listen 443 ssl;
server_name *.lande.xyz;
ssl_certificate /etc/nginx/cert/4610245_www.lande.xyz.pem;
ssl_certificate_key /etc/nginx/cert/4610245_www.lande.xyz.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #使用此加密套件。
ssl_prefer_server_ciphers on;
location / {
root /usr/share/nginx/html/edu;
try_files $uri /index.html
index index.html index.htm;
}
}