1、Https过程

Https过程

 

 

2、Nginx配置https

1)生成私钥和公钥

 命令:openssl req -x509 -newkey rsa:2048 -nodes -sha256 -keyout localhost-privkey.pem -out localhost-cert.pem

Https过程

 

 

 

2)、配置test.conf文件

server{
  listen 443;
  server_name test.com;

  ssl on;
  ssl_certificate_key ../certs/localhost-privkey.pem;
  ssl_certificate ../certs/localhost-cert.pem;

  location / {
	proxy_pass http://127.0.0.1:7080;
  	proxy_set_header Host $host;
  }
}

  

 

3) host文件配置如下(C:\Windows\System32\drivers\etc下)

Https过程

 

 

 

 

4) 使用https访问

Https过程

 

 说明已经配置成功

 

5) 实现访问http时,直接跳转到https

server{
  listen 80 default_server;
  listen [::]:80 default_server;
  server_name test.com;
  return 302 https://$server_name$request_uri;
}


server{
  listen 443;
  server_name test.com;

  ssl on;
  ssl_certificate_key ../certs/localhost-privkey.pem;
  ssl_certificate ../certs/localhost-cert.pem;

  location / {
	proxy_pass http://127.0.0.1:7080;
  	proxy_set_header Host $host;
  }
}

  

 

相关文章:

  • 2021-06-23
  • 2021-06-07
  • 2021-07-30
  • 2021-04-07
  • 2021-10-25
猜你喜欢
  • 2021-09-08
  • 2021-04-06
  • 2021-07-11
  • 2021-11-12
相关资源
相似解决方案