docker-nginx
有时候需要跑一些简单的静态网页,通过docker跑nginx来实现,将配置文件及网页文件路径映射到外部来。
安装nginx镜像
如果没有安装过nginx镜像需要先下载一下(不安装也可,运行命令时会自动下载的)
1
| docker pull nginx:latest
|
运行命令
1 2 3 4 5 6 7
| docker run -d \ --name uestc-gate \ -p 12080:80 \ -p 12443:443 \ -v /data/uestc-gate/web/:/usr/share/nginx/html/ \ --restart always \ nginx
|
HPPTS
https://www.cnblogs.com/tandk-blog/p/15449873.html
用mount才能让容器内的先复制出来,挂载的路径在/var/lib/docker/volumes/中,证书也放在其中
1 2 3 4
| docker run -d -p 11080:80 -p 11443:443 \ --restart always \ --mount source=cicd-hexo-data,destination=/etc/nginx \ --name cicd-hexo cicd-hexo
|
修改defualt.conf:
defualt.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| server { listen 443 ssl; server_name alfredty.com;
ssl_certificate /etc/nginx/7657087_alfredty.com.pem; ssl_certificate_key /etc/nginx/7657087_alfredty.com.key; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3; ssl_prefer_server_ciphers on;
location / { root /usr/share/nginx/html; index index.html index.htm; } }
server { listen 80; server_name alfredty.com; rewrite ^(.*)$ https://$host$1; location / { root /usr/share/nginx/html; index index.html index.htm; } }
|