Home>Article>Operation and Maintenance> Where to add ssl certificate to nginx
Due to project requirements and security reasons, the previous http interface access needs to be changed to https access, so an SSL certificate needs to be configured.
#SSL certificates are roughly divided into three types, domain level (DV), enterprise level (OV), and enhanced level (EV), with security and price increasing in order. Choose according to your own needs. For personal use, you can use DV, which is cheap; for corporate use, OV is generally used, and EV is used under special circumstances.
SSL Certificate Configuration
Because Nginx’s support for SSL certificate configuration makes this implementation possible, I have to lament the power of Nginx.
Put the domain name certificate: Configure it as follows under the /etc/nginx/ssl.conf folder.
Configuration example:
server { listen 443; server_name www.domain.com; # 改为绑定证书的域名 ssl on; ssl_certificate 1_www.domain.com_bundle.crt; # 改为自己申请得到的 crt 文件的名称 ssl_certificate_key 2_www.domain.com.key; # 改为自己申请得到的 key 文件的名称 ssl_session_timeout 5m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; ssl_prefer_server_ciphers on; location / { root /usr/share/nginx/html; #站点目录 index index.html index.htm; } }
After modifying the configuration, restart the nginx service
nginx -s reload //使配置生效
Use https protocol to access your domain name, such as https:// jikexianfeng.xyz//hello.html (your own domain name) Check whether it is successful. If a green lock sign with the word security appears in the address bar, it means that the SSL configuration has been successful.
For more Nginx related technical articles, please visit theNginx usage tutorialcolumn to learn!
The above is the detailed content of Where to add ssl certificate to nginx. For more information, please follow other related articles on the PHP Chinese website!