How to configure nginx https 443 port?

2023-10-16 14:42:24

1. Log in to Alibaba Cloud or Tencent Cloud and download the free certificate

Second, click nginx to download and upload to the server

Three nginx configuration https protocol server {listen 443 ssl; server_name xxx.com ; Ssl_certificate cert/ downloaded pem suffix file; Ssl_certificate_key cert/ downloaded key suffix file; ssl_session_timeout 120m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers ALL:! ADH:! EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP; ssl_prefer_server_ciphers on; Location/{proxy_pass http:// the forwarding path (consistent with http)/; #proxy_set_header X-Real-IP $remote_addr; #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #proxy_set_header Host $http_host; #proxy_set_header X-NginX-Proxy true; # Because of the reverse proxy of nginx, it is necessary to assign $remote_addr to a parameter here, and the system obtains the user's access ip through this parameter, which is directly defined as: wl-proxy-client-IP proxy _ set _ header wl-proxy-client-IP $ remote _ addr; proxy_redirect default; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }

At this point, nginx has completed the configuration of https. If the configuration is not effective, please check whether the downloaded pem and key files have correct paths.

Execute the nginx restart command: systemctl restart nginx.service can be applied.


Copyright Description:No reproduction without permission。

Knowledge sharing community for developers。

Let more developers benefit from it。

Help developers share knowledge through the Internet。

Follow us