【发布时间】:2017-05-19 09:52:25
【问题描述】:
我将 docker-compose 用于 Rails 应用程序以拥有应用程序和数据库容器。为了测试某些应用功能,我需要 SSL...所以我将使用 LetsEncrypt 与自签名。
app使用nginx,服务器是ubuntu 14.04 lts,以phusion乘客docker镜像为基础镜像(轻量级debian)
通常使用 LetsEncrypt,我运行通常的 ./certbot-auto certonly --webroot -w /path/to/app/public -d www.example.com
我的服务器运行 nginx(代理将应用程序传递给容器),所以我跳入容器运行 certbot 命令没有问题。
但是,当我尝试转到 https://test-app.example.com 时,它不起作用。我不知道为什么。
现场错误(Chrome):
This site can’t be reached
The connection was reset.
Curl 给出了更好的错误:
curl: (35) Unknown SSL protocol error in connection to test-app.example.com
服务器 nginx app.conf
upstream test_app { server localhost:4200; }
server {
listen 80;
listen 443 default ssl;
server_name test-app.example.com;
# for SSL
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_dhparam /etc/ssl/dhparam.pem;
ssl_prefer_server_ciphers on;
ssl_ciphers 'ECDHE-RSA-blahblahblah-SHA';
location / {
proxy_set_header Host $http_host;
proxy_pass http://test_app;
}
}
容器的 nginx app.conf
server {
server_name _;
root /home/app/test/public;
ssl_certificate /etc/letsencrypt/live/test-app.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/test-app.example.com/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_dhparam /etc/ssl/dhparam.pem;
ssl_prefer_server_ciphers on;
ssl_ciphers 'ECDHE-RSA-blahblah-SHA';
passenger_enabled on;
passenger_user app;
passenger_ruby /usr/bin/ruby2.3;
passenger_app_env staging;
location /app_test/assets/ {
passenger_enabled off;
alias /home/app/test/public/assets/;
gzip_static on;
expires +7d;
add_header Cache-Control public;
break;
}
}
在我的 Dockerfile 中,我有:
# expose port
EXPOSE 80
EXPOSE 443
在我的 docker-compose.yml 文件中,我有:
test_app_app:
build: "."
env_file: config/test_app-application.env
links:
- test_app_db:postgres
environment:
app_url: https://test-app.example.com
ports:
- 4200:80
docker ps 显示为:
Up About an hour 443/tcp, 0.0.0.0:4200->80/tcp
我现在怀疑这是因为服务器的 nginx——“前置”服务器——没有证书,但我无法在没有应用程序位置的情况下运行 LetsEncrypt 命令。
我尝试在服务器上运行手动 LetsEncrypt 命令,但因为我大概暴露了 80 端口,所以我得到了这个:socket.error: [Errno 98] Address already in use我在这里错过了什么吗?
我该怎么办?
【问题讨论】:
标签: ruby-on-rails ssl nginx docker-compose lets-encrypt