HTTP 访问
模块引入
**docker network rm feng-net**
**docker network create feng-net**
启动模块
**docker rm -f nginx-proxy**
**docker run -p 80:80 -p 443:443 \**
** -d \**
**--name nginx-proxy \**
**--network feng-net \**
**--network-aliasnginx-proxy-host\**
**-v/usr/share/nginx/html\**
**-v/etc/nginx/vhost.d \**
**-v/var/run/docker.sock:/tmp/docker.sock:ro \**
**jwilder/nginx-proxy**
绑定域名
示例A站
**docker rm -f www**
**docker run \**
**-d \**
**-e VIRTUAL_HOST=www.fengnz.tk \**
**--network feng-net \**
**--network-alias www-host \**
**--name www \**
**-p 81:80 \**
**nginxdemos/hello**
示例B站
**docker rm -f bbs**
**docker run \**
**-d \**
**-e VIRTUAL_HOST=bbs.fengnz.tk \**
**--network feng-net \**
**--network-alias bbs-host \**
**--name bbs \**
**-p 82:8000 \**
**crccheck/hello-world**
**docker run --name web-test1 -p 80:80 -d --rmnginxdemos/hello**
**docker run --name web-test2 -p 80:8000 -d --rmcrccheck/hello-world**
HTTPS 访问
模块删除与引用
**docker network rm feng-net**
docker network create feng-net
创建运行访问服务
**docker rm -f nginx-proxy**
docker run -p 80:80 -p 443:443 \
-d \
—name nginx-proxy \
—network feng-net \
—network-alias nginx-proxy-host\
-v/usr/share/nginx/html\
-v/etc/nginx/vhost.d \
-v/var/run/docker.sock:/tmp/docker.sock:ro \
jwilder/nginx-proxy
创建证书路径
**docker rm -f nginx-proxy**
docker run -p 80:80 -p 443:443 \
-d \
—name nginx-proxy \
—network feng-net \
—network-alias nginx-proxy-host\
-v /root/ssl:/etc/nginx/certs:ro \
-v/etc/nginx/vhost.d \
-v/usr/share/nginx/html\
-v/var/run/docker.sock:/tmp/docker.sock:ro \
—label com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy \
jwilder/nginx-proxy
**docker rm -f companion**
docker run \
-d \
—name companion \
—network feng-net \
—network-alias companion-host \
-v/home/fennng/certs:/etc/nginx/certs:rw \
-v/var/run/docker.sock:/var/run/docker.sock:ro \
—volumes-from nginx-proxy \
jrcs/letsencrypt-nginx-proxy-companion
创建证书
示例A站
**docker rm -f www**
docker run \
-d \
-e VIRTUAL_HOST=www.fengnz.tk \
-e “LETSENCRYPT_HOST=www.fengnz.tk”\
-e “LETSENCRYPT_EMAIL=soody@qq.com”\
—network feng-net \
—network-alias www-host \
—name www \
-p 81:80 \
nginxdemos/hello
示例A站
**docker rm -f bbs**
docker run \
-d \
-e VIRTUAL_HOST=bbs.fengnz.tk \
-e “LETSENCRYPT_HOST=bbs.fengnz.tk”\
-e “LETSENCRYPT_EMAIL=soody@qq.com”\
—network feng-net \
—network-alias bbs-host \
—name bbs \
-p 82:8000 \
crccheck/hello-world
docker run —name web-test1 -p 80:80 -d —rmnginxdemos/hello
docker run —name web-test2 -p 80:8000 -d —rmcrccheck/hello-world