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

Methods and steps of upgrading https under Nginx

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

Share

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

Purchase certificate

You can go to Aliyun's cloud shield certificate service to purchase

Download certificate

Download the Nginx version certificate in the Certificate console. The compressed file package downloaded to the local file package is decompressed and contains:

.pem file: certificate file. key file: the private key file of the certificate (if you do not choose to automatically create a CSR when applying for a certificate, there is no such file)

Configure Nginx

1. Create the cert directory under the installation directory of Nginx, and copy all the downloaded files to the cert directory. If you created the CSR file when applying for the certificate, put the corresponding private key file in the cert directory.

2. Open the nginx.conf file in the conf directory under the Nginx installation directory

# user nobody;worker_processes 1 the errorless log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info;#pid logs/nginx.pid;events {worker_connections 1024;} http {include mime.types; default_type application/octet-stream # log_format main'$remote_addr-$remote_user [$time_local] "$request" #'$status $body_bytes_sent "$http_referer" # "" $http_user_agent "" $http_x_forwarded_for "; # access_log logs/access.log main; sendfile on; # tcp_nopush on; # keepalive_timeout 0; keepalive_timeout 65; gzip on; # enable gzip gzip_min_length 1k # Resources lower than 1kb do not compress gzip_comp_level 3; # compression level [1-9], the greater the compression ratio, the higher the compression ratio, and the more cpu resources are consumed. It is recommended to set it to about 4. Gzip_types text/plain application/javascript application/x-javascript text/javascript text/xml text/css; # needs to compress resources of which response types, separated by multiple spaces. Compressing pictures is not recommended. Here's why. Gzip_disable "MSIE [1-6]\."; # configuration disables gzip conditions and supports regularities. This means that gzip is not enabled in ie6 and below (because the lower version of ie does not support it) gzip_vary on; # whether to add the "Vary: Accept-Encoding" response header server {listen 80 default backlog=2048; # configuration http available listen 443 ssl; # configuration https server_name localhost; ssl_certificate. / cert/hzzly.pem; # configuration certificate file ssl_certificate_key.. / cert/hzzly.key # configure the private key file ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers High _ proxy_set_header X-Real-IP _ blank _ MD5; ssl_prefer_server_ciphers on; location / {root / home/hzzly; index index.html index.htm;} # location ^ ~ / apis/ {# proxy_set_header Host $host; # proxy_set_header X-Real-IP $remote_addr # proxy_set_header X-Forwarded-Server $host; # # matches any request that starts with / apis/ and stops matching other location # proxy_pass http://xxxxxxxxxx/; #} # location ^ ~ / assets/ {# gzip_static on; # expires max; # add_header Cache-Control public; #}}

3. Restart Nginx

$cd / usr/local/nginx/sbin$. / nginx-s reload

Error explanation

1. Nginx if the SSL module is not enabled, an error occurs when configuring Https

Nginx: [emerg] the "ssl" parameter requires ngx_http_ssl_module in

Nginx opens the SSL module

Switch to the source code package:

$cd / usr/local/src/nginx-1.16.0

Modify new configure parameters

$. / configure-prefix=/usr/local/nginx-with-http_stub_status_module-with-http_ssl_module

After the configuration is complete, run the command

$make / / do not do make install here, otherwise you will overwrite the installation

Back up the original installed nginx

$cp / usr/local/nginx/sbin/nginx / usr/local/nginx/sbin/nginx.bak

Overwrite the newly compiled nginx with the original nginx

$cp. / objs/nginx / usr/local/nginx/sbin/

Restart Nginx

$cd / usr/local/nginx/sbin$. / nginx-s reload

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

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

Servers

Wechat

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

12
Report