- File CSR, SSL là gì?
- Hướng dẫn tạo file CSR.
- 1. Tạo thư mục chứa file SSL.
- 2. Tạo file key với độ dài 2048 bit.
- 3. Tạo file CSR.
- 4. Dùng Winscp lấy key và CSR file.
- Hướng dẫn cài đặt SSL cho domain.
- 1. Cài đặt Nginx.
- 2. Tạo RSA private key.
- 3. Đổi tên file từ server.temp.key thành server.key.
- 4. Xóa file server.temp.key.
- 5. Tạo file CSR.
- 6. Tạo file CRT.
- 7. Cài đặt SSL trong Nginx.
- Kết Luận:
File CSR, SSL là gì?
CSR (Certificate Signing Request) là 1 đoạn text (chứa thông tin của chủ sở hữu tên miền) được mã hóa từ server (máy chủ) chuẩn bị cho việc cài đặt CSR SSL.
Nó chứa các thông tin bao gồm trong giấy chứng nhận của bạn như tên tổ chức của bạn, tên thông thường (tên miền), địa phương và quốc gia. 1 CSR sẽ được tạo ra ngay trước khi gửi yêu cầu cho bên cung cấp SSL để sinh ra SSL.
SSL là viết tắt của từ Secure Sockets Layer. Đây là một tiêu chuẩn an ninh công nghệ toàn cầu tạo ra một liên kết giữa máy chủ web và trình duyệt. Liên kết này đảm bảo tất cả dữ liệu trao đổi giữa máy chủ web và trình duyệt luôn được bảo mật và an toàn.SSL đảm bảo rằng tất cả các dữ liệu được truyền giữa các máy chủ web và các trình duyệt được mang tính riêng tư, tách rời. SSL là một chuẩn công nghệ được sử dụng bởi hàng triệu trang web trong việc bảo vệ các giao dịch trực tuyến với khách hàng của họ.
Hướng dẫn tạo file CSR.
1. Tạo thư mục chứa file SSL.
mkdir your_domain
cd your_domain
2. Tạo file key với độ dài 2048 bit.
openssl genrsa -out your_domain.key 2048
3. Tạo file CSR.
openssl req -new -key your_domain.key -out your_domain.csr
Bạn sẽ nhập vào các thông tin sau đây:
Country Name (2 letter code) [XX]: Country Name (Only 2 characters)
State or Province Name (full name) []: province/city
Locality Name (eg, city) [Default City]: city name
Organization Name (eg, company) [Default Company Ltd]: company name
Organizational Unit Name (eg, section) []:
Common Name (eg, your name or your server's hostname) []:servername or hostname
Email Address []:email
Ví dụ:
Country Name (2 letter code) [XX]:VN
State or Province Name (full name) []:Ho Chi Minh
Locality Name (eg, city) [Default City]:Ho Chi Minh
Organization Name (eg, company) [Default Company Ltd]:vhost.vn
Organizational Unit Name (eg, section) []:vhost.vn
Common Name (eg, your name or your server's hostname) []:vhost.vn
Email Address []:support@vhost.vn
4. Dùng Winscp lấy key và CSR file.
Hướng dẫn cài đặt SSL cho domain.
1. Cài đặt Nginx.
Bài viết trước, mình đã giới thiệu các bạn cách cài đặt nginx, các bạn có thể tham khảo tại đây.
2. Tạo RSA private key.
sudo openssl genrsa -des3 -passout pass:odoo -out server.temp.key 2048
Bạn sẽ thấy xuất hiện giống hình dưới đây.
Bạn sẽ được yêu cầu nhập một password bảo mật hơn và xác nhận lại password.

Lưu ý: Nếu bạn sử dụng CERTIFICATE AUTHORITY thì làm theo cách sau.
sudo openssl req -new -passin pass:odoo -key server.key -out server.csr
Bạn chạy câu trên sẽ được kết quả như sau.
3. Đổi tên file từ server.temp.key thành server.key.
sudo mv server.key server.temp.key
sudo openssl rsa -in server.temp.key -out server.key
4. Xóa file server.temp.key.
sudo rm server.temp.key
5. Tạo file CSR.
sudo openssl req -new -key server.key -out server.csr
6. Tạo file CRT.
sudo openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
Lưu ý:
365 là số ngày hết hạn.
7. Cài đặt SSL trong Nginx.
Bỏ nội dung sau vào file Nginx.
server {
listen 10.0.1.43:443 default;
server_name 10.0.1.43;
access_log /var/log/nginx/oddo.access.log;
error_log /var/log/nginx/oddo.error.log;
ssl on;
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
keepalive_timeout 60;
ssl_ciphers HIGH:!ADH:!MD5;
ssl_protocols SSLv3 TLSv1;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://127.0.0.1:port-odoo-server;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_buffer_size 128k;
proxy_buffers 16 64k;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header X-Forwarded-Proto https;
}
location ~* /web/static/ {
proxy_buffering off;
proxy_pass http://127.0.0.1:port-odoo-server;
}
}
Lưu ý:
Cho phép một IP tự động chuyển từ http sang https:
server {
listen IP-client:80;
server_name IP-client;
add_header Strict-Transport-Security max-age=2592000;
rewrite ^/.*$ https://$host$request_uri? permanent;
}
Cho phép một IP khi đã bookmark URL với port 8069 tự động chuyển sang https.
server {
listen 10.0.1.43:8069;
server_name 10.0.1.43;
add_header Strict-Transport-Security max-age=2592000;
rewrite ^/.*$ https://$host$request_uri? permanent;
}
Kết Luận:
Mình vừa giới thiệu đến các bạn cách cài đặt SSL certificate cho domain. Các bạn có thắc mắc gì có thể để lại comment chia sẽ bên dưới. Nếu bài viết có điều sai sót xin các bạn góp ý.
Cảm ơn các bạn theo dõi.
I love your blog.. very nice colors & theme.
Did you design this website yourself or did you hire someone
to do it for you? Plz reply as I’m looking to design my own blog
and would like to know where u got this from.
many thanks
Look at my site; pmp simulator (Lacy)
I do not even know pass the cpc exam (King) way I ended
up right here, but I believed this post used to be
good. I don’t understand who you’re but certainly you are going to a famous blogger
if you aren’t already. Cheers!
Hi there, always i used to check website posts here in the early hours in the break of
day, for the reason that i enjoy to find out more and more.
I precisely had to thank you very much yet again. I’m not certain the things I could possibly have
worked on in the absence of the actual advice
documented by you regarding this area. Completely was a
real frustrating issue in my opinion, however , looking
at a new skilled fashion you processed it made me to leap for fulfillment.
I will be grateful for your service and in addition pray you recognize what a powerful job your are getting into instructing
most people thru your web site. Most probably you have never
come across any of us.
Look into my web blog cpa exam anxiety (Sherryl)