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

How to configure ssl to implement https in Nginx

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces Nginx how to configure ssl to achieve https, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

First, install Nginx ssl module 1. Check

Check if the ssl module is installed:

Cd / usr/local/nginx/sbin./nginx-V [root@server-c00ef8c3-710d-4708-9cde-2c864e7c03e2 sbin] #. / nginx-Vnginx version: nginx/1.21.4built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) configure arguments:-- prefix=/usr/local/nginx

If configure arguments:-- with-http_ssl_module does not appear, it means it is not installed.

two。 Install cd / usr/local/nginx-1.21.4./configure-- prefix=/usr/local/nginx-- with-http_ssl_modulemakecp. / objs/nginx / usr/local/nginx/sbin/3. Check again

Check again to see if the ssl module is installed:

Cd / usr/local/nginx/sbin./nginx-V [root@server-c00ef8c3-710d-4708-9cde-2c864e7c03e2 sbin] #. / nginx-Vnginx version: nginx/1.21.4built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017TLS SNI support enabledconfigure arguments:-- prefix=/usr/local/nginx-- with-http_ssl_ module II, deployment ssl certificate

Copy the applied ssl certificate to the cert directory:

3. Configure nginx.confcd / usr/local/nginx/confvi nginx.conf

New https server configuration:

# Management side httpsserver {listen 443 ssl; server_name admin-xxxxx.xxx.xxx; ssl_certificate. / cert/server.crt; ssl_certificate_key.. / cert/server.key; ssl_session_timeout 5m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers ECDHEMurRSAmuri AES128MurGCMMurSHA256HIGHMUA NULLRV MD5RC4RC4R; ssl_prefer_server_ciphers on Location / {proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $http_host; proxy_pass http://localhost:10003;} IV. Restart Nginx/usr/local/nginx/sbin/nginx-s reload

Or

Ps-ef | grep nginxkill xxx/usr/local/nginx/sbin/nginx

Add: if port 80 is occupied, use kill [id] to end the process:

# View the port using $netstat-lntp

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name

Tcp 0 0 0.0.0.0:80 0.0.0.0: LISTEN 21307/nginx: master

Tcp 0 0 0.0.0.0:22 0.0.0.0: LISTEN 3072/sshd

Tcp 0 0 0.0.0.0:443 0.0.0.0???? LISTEN 21307/nginx: master

# end the port 80 process

$kill 21307

Restart nginx again:

$/ usr/local/nginx/sbin/nginx-c / usr/local/nginx/conf/nginx.conf Thank you for reading this article carefully. I hope the article "how to configure Nginx to implement https with ssl" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

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