Home > Operation and Maintenance > Nginx > How to install and deploy Nginx server SSL certificate in Windows environment

How to install and deploy Nginx server SSL certificate in Windows environment

王林
Release: 2023-05-15 09:37:05
forward
2718 people have browsed it

Nginx type server certificate compressed package

The contents of the certificate compressed folder are as follows (the domain name of baidu.com is used as an example here):

  • baidu.com_bundle. crt certificate file

  • baidu.com_bundle.pem certificate file (you can ignore this file)

  • baidu.com.key private key file

  • baidu.com.csr CSR file

Copy the certificate file and private key file

Copy the obtained baidu.com_bundle.crt Certificate file and baidu.com.key private key file are copied from the local directory to the conf directory under the Nginx root directory

Modify nginx.conf configuration

Edit the conf/nginx.conf file in the Nginx root directory. The modifications are as follows:

# HTTPS server
#
server {
    #SSL 默认访问端口号为 443
    listen                  443 ssl;
    #请填写绑定证书的域名
    server_name             baidu.com www.baidu.com;

    #请填写证书文件的相对路径或绝对路径
    ssl_certificate         baidu.com_bundle.crt;
    #请填写私钥文件的相对路径或绝对路径
    ssl_certificate_key     baidu.com.key;

    ssl_session_cache       shared:SSL:1m;
    ssl_session_timeout     5m;

    #请按照以下协议配置
    ssl_protocols           TLSv1.2 TLSv1.3;

    #请按照以下套件配置,配置加密套件,写法遵循 openssl 标准。
    ssl_ciphers             ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
    ssl_prefer_server_ciphers on;

    location / {
        #网站主页路径。此路径仅供参考,具体请您按照实际目录操作。
        #root    html;
        proxy_pass   http://127.0.0.1:8080;
        index   index.html index.htm;
    }
}
Copy after login

HTTP automatic jump to HTTPS security configuration (optional)

server {
    listen 80;
    #请填写绑定证书的域名
    server_name baidu.com www.baidu.com;
    #把http的域名请求转成https
    return 301 https://$host$request_uri;
}
Copy after login

Check and restart the Nginx service

Start the cmd command line in the Nginx root directory

1. Test whether the Nginx configuration is correct

nginx -t
Copy after login

Graceful restart

nginx -s reload
Copy after login

The above is the detailed content of How to install and deploy Nginx server SSL certificate in Windows environment. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template