0%

Nginx_配置SSL证书

Nginx配置域名的SSL证书

  1. 获取证书并上传到Ngx服务器

  1. 检查Ngx是否安装–with-http_ssl_module模块

  1. 修改nginx配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
server {
listen 80;
server_name *.zhaohongye.com;
#return 301 https://$host$request_uri;
return 301 https://zhaohongye.com;
}

server {
listen 443 ssl;
server_name zhaohongye.com www.zhaohongye.com;
access_log /var/log/nginx/zhy.log main;
error_log /var/log/nginx/zhy.error.log;

ssl on; #ssl功能开启
ssl_certificate sslfile/2027481_zhaohongye.com.pem;
ssl_certificate_key sslfile/2027481_zhaohongye.com.key;


location / {
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect http:// https://;
proxy_pass http://127.0.0.1:4000;
client_max_body_size 10M;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
# Required for new HTTP-based CLI
proxy_http_version 1.1;
proxy_request_buffering off;
}
}
  1. https访问验证