我一直在尝试使用 Docker Machine 和 Docker Compose 部署容器。我正在运行Windows 10和适用于 Windows 的 docker v1.12.5。
当我启动配置时,我运行以下命令:
docker-machine env my-machine
& "C:\Program Files\Docker\Docker\Resources\bin\docker-machine.exe" env my-machine | Invoke-Expression
这将使我的机器处于活动状态
之后我想部署我的配置,它有一个nginx 代理和一个nodejs应用程序。在这个代理上我配置了 2 个站点。
server {
listen 443 ssl;
server_name mysite.com;
access_log /var/log/nginx/mysite.log;
error_log /var/log/nginx/mysite.log;
location / {
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://myapp:8080/;
proxy_redirect off;
}
location ^~ /.well-known/acme-challenge {
root /usr/share/nginx/html;
default_type "text/plain";
}
ssl_certificate /etc/letsencrypt/live/msite.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mysite.com/privkey.pem;
ssl_session_cache shared:le_nginx_SSL:1m;
ssl_session_timeout 1440m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_stapling on;
ssl_stapling_verify on;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
ssl_ciphers "ECDHE-ECDSA-AES128-GCM-SHA256 ECDHE-ECDSA-AES256-GCM-SHA384 ECDHE-ECDSA-AES128-SHA ECDHE-ECDSA-AES256-SHA ECDHE-ECDSA-AES128-SHA256 ECDHE-ECDSA-AES256-SHA384 ECDHE-RSA-AES128-GCM-SHA256 ECDHE-RSA-AES256-GCM-SHA384 ECDHE-RSA-AES128-SHA ECDHE-RSA-AES128-SHA256 ECDHE-RSA-AES256-SHA384 DHE-RSA-AES128-GCM-SHA256 DHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES128-SHA DHE-RSA-AES256-SHA DHE-RSA-AES128-SHA256 DHE-RSA-AES256-SHA256 EDH-RSA-DES-CBC3-SHA";
}
server {
listen 8000;
server_name mysite;
return 301 https://$host$request_uri;
}
Nginx现在应该获得一个证书,为此我发现我可以使用它letsencrypt-nginx-proxy-companion
可以生成并管理我的网站的证书。
我对这个同伴的配置如下:
letsencrypt-nginx-proxy-companion:
image: jrcs/letsencrypt-nginx-proxy-companion
volumes_from:
- nginx
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- nginx_certs:/etc/nginx/certs:rw
environment:
- NGINX_DOCKER_GEN_CONTAINER=nginx-gen
每次运行时docker-compose up -d
我都会收到以下错误消息:
对于 letsencrypt-nginx-proxy-companion 无法为服务 letsencrypt-nginx-proxy-companion 创建容器:创建 \var\run\docker.sock:“\var\run\docker.sock”包含本地卷名的无效字符,仅允许“[a-zA-Z0-9][a-zA-Z0-9_.-]”
希望有人能帮助我修复这个错误。