DEV Community

NGINX Set Let's Encrypt

set Https บน nginx ด้วย Let's Encrypt


How to start

- Step 1 install certbot

$ sudo add-apt-repository ppa:certbot/certbot

- Step 2 install Certbot’s Nginx package

$ sudo apt install python-certbot-nginx

- Step 3 edit config on Site Available

$ sudo nano /etc/nginx/sites-available/default

/etc/nginx/sites-available/default

...
server_name example.com www.example.com;
...

- Step 4 restart nginx

$ sudo systemctl restart nginx

- Step 5 certbot

sudo certbot --nginx -d <example.com> -d www.<example.com>

output and select 2

Output
Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
-------------------------------------------------------------------------------
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
-------------------------------------------------------------------------------
Select the appropriate number [1-2] then [enter] (press 'c' to cancel):

- open https with https://example.com

Top comments (0)