6 months ago

感谢

https://gorails.com/guides/free-ssl-with-rails-and-nginx-using-let-s-encrypt

linode ubuntu 16.04.02 安装let’s encrypt

首先这个版本的ubuntu没有add-apt-repository,所以要先安装相关的包

sudo apt-get install software-properties-common python-software-properties

然后安装certbot

sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install certbot

假设rails 运行在 /home/doudouappadmin/videopk/current/public

sudo letsencrypt certonly --webroot --webroot-path /home/doudouappadmin/videopk/current/public --renew-by-default --email lilin@myrual.me --text --agree-tos  -d dd.doudouapp.com

然后编辑nginx配置文件来启用ssl

sudo vim /opt/nginx/conf/nginx.conf

打开ssl 相关内容
然后

server {
    listen       443 ssl;
    server_name  dd.doudouapp.com;

    ssl_certificate      /etc/letsencrypt/live/dd.doudouapp.com/fullchain.pem;
    ssl_certificate_key  /etc/letsencrypt/live/dd.doudouapp.com/privkey.pem;

    ssl_session_cache    shared:SSL:1m;
    ssl_session_timeout  5m;

    ssl_ciphers  HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers  on;

    root /home/doudouappadmin/videopk/current/public;
    passenger_enabled on;
    client_max_body_size 30M;
}

然后用ngix 校验一下语法

sudo nginx -t
← 观察民主的一个角度 add JSON API to devise gem in rails →