1. Install nginx

  • Go to thenginxWebsite innginx Nginx.org/en/download…

  • Unzip the downloaded file and change the file name to nginx. Then copy the file to disk C as follows:

  • Run nginx
start nginx
Copy the code
  • validation
Enter localhost in the browser. If the following page is displayed, the installation is successfulCopy the code

2. Install OpenSSL

  • Download OpenSSL

  • Slproweb.com/products/Wi…

  • Download to C:\ OpenSSL-win64

  • Configuring environment Variables

%OPENSSL_HOME%

3. Generate an HTTPS certificate

  • Create an SSL folder under C:\nginx to store the certificate
  • Create private key (recommended to use system window, do not use gitBash there is a selection involved, gitBash cannot select)
Key 1024 // The name specified by the shidian userCopy the code

The effect is as follows:

  • Creating a CSR Certificate
openssl req -new -key shidian.key -out shidian.csr
Copy the code

  • Deleting password Replicationshidian.keyAnd renameshidian.key.org

openssl rsa -in shidian.key.org -out shidian.key

  • Generating a CRT Certificate

openssl x509 -req -days 365 -in shidian.csr -signkey shidian.key -out shidian.crt

  • Finally, the following certificate is generated

Modify the nginx.conf configuration file under nginx

C:\nginx\conf\nginx.conf
Copy the code
Upstream nodejs__upstream2 {server 127.0.0.1:8080;I used the port name to listen on
	keepalive 64;
}

server {
	listen 443 ssl;
	server_name dev.kt.looklook.cn; # configure HTTPS domain name

	ssl_certificate      C://nginx//ssl//shidian.crt;  This is where the CRT file of the certificate resides
	ssl_certificate_key  C://nginx//ssl//shidian.key;  This is the directory where the certificate key file residesssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:! aNULL:! MD5; ssl_prefer_server_ciphers on; location / { 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;
	proxy_set_header   Connection ""; Proxy_http_version 1.1; proxy_pass http://nodejs__upstream2; }}Copy the code
  • Restart the nginx
nginx -s reload
Copy the code
  • Configuring the Host File
C: Windows\System32\drivers\etc 127.0.0.1 dev.kt.looklook.cn# Domain name to be configured
Copy the code
  • access
Enter your configured domain name to accessCopy the code