Kích Hoạt HTTPS Miễn Phí Cho Trang Web

Chuẩn bị

Cập nhật Hệ điều hành: $ sudo apt-get update
Cài Let’s Encrypt:
$ mkdir /opt/letsencrypt
$ cd /opt/letsencrypt
$ wget https://dl.eff.org/certbot-auto
$ chmod a+x ./certbot-auto

Kích hoạt HTTPS

Bước 1: Dừng lại NGINX

$ sudo service nginx stop

Bước 2: Cài chứng chỉ kỹ thuật số

$ sudo ./certbot-auto certonly –standalone -d viettechgroup.com -d www.viettechgroup.com

Bước 3: Cấu hình NGINX viettechgroup.conf

$ sudo nano /etc/nginx/sites-enabled/viettechgroup.conf
Sửa lại như sau:
server {
listen 80;
listen [::]:80;
root /var/www/viettechgroup;
index index.html index.htm index.nginx-debian.html index.php;
server_name viettechgroup.com www.viettechgroup.com;
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/viettechgroup.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/viettechgroup.com/privkey.pem;
if ($scheme != “https”) {
return 301 https://$host$request_uri;
}
location /favicon.ico {
log_not_found off;
access_log off;
}
location /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
}
location ~* .(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}

Bước 4: Chạy lại NGINX

$ sudo service nginx start

Leave a comment

Your email address will not be published.