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

NGINX how to turn on HTTPS

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article introduces the relevant knowledge of "how to open HTTPS with NGINX". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Free SSL certificate application

To open HTTPS, you must apply for a SSL certificate. Many fee-based SSL certificates are expensive, often tens of thousands of them a year. Fortunately, both Aliyun and Tencent Cloud have free SSL certificates to apply for, making it a zero-cost thing to enable HTTPS.

Take Tencent Cloud as an example. Go to the Tencent Cloud console, click Cloud products, and find the SSL certificate:

Click my Certificate-apply for a free certificate:

Select Asian Integrity Free Edition Certificate and click OK:

Next, fill in the information as required by Tencent Cloud and verify the domain name:

Note that each subdomain name needs to be applied separately. After passing the application and verification, you can click to download:

After downloading and decompressing, you get the following file:

Upload the files in the Nginx directory to the server:

Nginx enables HTTPS

Reference: Configuring HTTPS servers

Add the following configuration to the nginx configuration file:

Server {listen 443 ssl; server_name www.example.com; ssl_certificate www.example.com.crt; ssl_certificate_key www.example.com.key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers high / Md 5;...}

Server_name is changed to its own domain name, and ssl_certificate and ssl_certificate_key are changed to the absolute address of their certificate.

Integration of Nginx and Tomcat

Nginx uses reverse proxy to integrate documents with tomcat: CentOS7 server build-NGINX

Centos builds documentation for self-starting tomcat: CentOS7 Server Building-Tomcat

Nginx configure http to jump to https

After you configure https, be sure to redirect http's request to https. Otherwise, either the http request cannot be accessed, or the user is still visiting the http website.

Nginx adds the following configuration:

Server {listen 80; server_name www.example.com; rewrite ^ (. *) $https://www.example.com/$1 permanent;} restart Nginx

Once configured, restart nginx is complete. Take centos7 as an example:

This is the end of systemctl restart nginx's "how to start HTTPS with NGINX". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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: 0

*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

Development

Wechat

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

12
Report