Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Tutorials for deploying SSL certificates and redirecting to HTTPS under Nginx

2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Step 1: download the certificate file of Nginx version. After decompressing it, you can see a .key file and a .crt / .pem file.

Step 2: upload the certificate. Upload the above .key file and .crt / .pem file to the / root directory and name them ssl.crt/ssl.pem and ssl.key

Step 3: the Nginx of the LNMP one-click installation package is configured in the / usr/local/nginx/conf/vhost/ directory, and find the configuration file (such as anxinssl.com) of the corresponding site domain name. The Nginx configuration file for a normal installation is in / etc/nginx/nginx.conf. The vi command enters the modification.

Modify it to:

Server {

Listen 443

Change server_name anxinssl.com http://www.anxinssl.com;# to your domain name

Ssl on

Root html

Index index.html index.htm

Ssl_certificate / root/ssl.pem

Ssl_certificate_key / root/ssl.key

Ssl_session_timeout 5m

Ssl_ciphers ECDHEMUR AES128MUG GCMMuSHA256 Flex ECDHEVE ECDH Von AESHV Highi A null LV A null L RC4 A null L RC4

Ssl_protocols TLSv1 TLSv1.1 TLSv1.2

Ssl_prefer_server_ciphers on

Location / {

Root html

Index index.html index.htm

}

}

Step 4: set 301 to redirect to HTTPS

Server

{

Listen 80

Server_name anxinssl.com http://www.anxinssl.com; # changed to your domain name

Rewrite ^ / (. *) https://anxinssl.com/$1 permanent; # if your website has www, please add www before the domain name

}

Server

{

Listen 443

#. The remaining configurations are the same as above

}

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 237

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report