nginx配置ssl
nginx配置ssl
中文
配置
这个需要nginx安装了 SSL模块 才行。
核心配置如下:
ssl_certificate /usr/local/nginx/ssl/nginx.crt;
ssl_certificate_key /usr/local/nginx/ssl/nginx.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
完整示例如下:
server {
listen 443 ssl;
server_name localhost;
ssl_certificate /usr/local/nginx/ssl/nginx.crt;
ssl_certificate_key /usr/local/nginx/ssl/nginx.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
#禁止在header中出现服务器版本,防止黑客利用版本漏洞攻击
server_tokens off;
#如果是全站 HTTPS 并且不考虑 HTTP 的话,可以加入 HSTS 告诉你的浏览器本网站全站加密,并且强制用 HTTPS 访问
fastcgi_param HTTPS on;
fastcgi_param HTTP_SCHEME https;
access_log /usr/local/nginx/logs/httpsaccess.log;
root /home/movie/;
location / {
proxy_set_header X-Forwarded-For $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:55055;
}
location /mp4 {
index index.html index.htm;
}
}
根据上面的描述,需要两个文件:nginx.crt、nginx.key两个文件。那么,这两个文件如何来的呢?
参照:
https://www.cnblogs.com/hnxxcxg/p/7610582.html
https://www.cnblogs.com/qiumingcheng/p/12024280.html
https://baijiahao.baidu.com/s?id=1649462735958571118&wfr=spider&for=pc