Nginx篇
ssl证书
分类
单域名证书
多域名证书
通用证书
网址
freessl
ohttps
ssh-keygen -R 114.132.70.81
www.lingyanspace.com_bundle.crt www.lingyanspace.com_bundle.pem www.lingyanspace.com.csr www.lingyanspace.com.key
/etc/nginx/www.lingyanspace.com_nginx
编译
yum install prel
yum install pcre cpre-devel
sudo yum install libxml2 libxml2-devel libxslt libxslt-devel
sudo yum install gd gd-devel
load_module /usr/lib64/nginx/modules/ngx_http_image_filter_module.so
load_module /usr/lib64/nginx/modules/ngx_http_perl_module.so
load_module /usr/lib64/nginx/modules/ngx_http_xslt_filter_module.so
load_module /usr/lib64/nginx/modules/ngx_mail_module.so
load_module /usr/lib64/nginx/modules/ngx_stream_module.so
#vod caches
vod_metadata_cache metadata_cache 256m;
vod_response_cache response_cache 128m;
# vod settings
vod_mode local;
vod_segment_duration 2000; # 2s
vod_align_segments_to_key_frames on;
#file handle caching / aio
open_file_cache max=1000 inactive=5m;
open_file_cache_valid 2m;
open_file_cache_min_uses 1;
open_file_cache_errors on;
aio on;
#课程权限文件夹
location /LimitVideo/ {
auth_request /test_auth;
alias /home/lingyanspace/LimitVideo/;
vod hls;
add_header Access-Control-Allow-Headers '*';
add_header Access-Control-Expose-Headers 'Server,range,Content-Length,Content-Range';
add_header Access-Control-Allow-Methods 'GET, HEAD, OPTIONS';
add_header Access-Control-Allow-Origin '*';
expires 100d;
}
location =/test_auth {
proxy_pass http://127.0.0.1:7777/LimitVideo;
proxy_pass_request_body off;
proxy_set_header X-Original-URI $request_uri;
proxy_set_header X-Original-Method $request_method;
proxy_set_header X-Forwarded-Proto $scheme;
}
//路径标识
public string LimitVideo = "LimitVideo";
public string LimitFile = "LimitFile";
public string OpenFile = "OpenFile";
生成dhparam.pem
文件
//当Nginx服务器与客户端建立SSL/TLS连接时,会使用DH参数进行密钥交换。
//这个过程允许双方在不安全的网络环境下协商出一个共享的密钥,而不需要直接传输密钥本身,从而保证了密钥的安全性。
//例如,假设一个Web服务器(使用Nginx)要与一个Web浏览器建立安全连接。
//在SSL/TLS握手阶段,服务器和客户端会根据ssl_dhparam指定的参数文件中的DH参数进行复杂的数学运算,以生成共享的加密密钥。
//这个共享密钥随后将用于加密和解密在连接中传输的数据
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
nginx通用前置配置
http {
# 包含MIME类型定义文件
include mime.types;
# 设置默认的MIME类型
default_type application/octet-stream;
# 定义日志格式
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
# 设置访问日志路径和使用的日志格式
access_log logs/access.log main;
# 开启sendfile功能,提高文件传输性能
sendfile on;
# 设置客户端连接的keep - alive超时时间
keepalive_timeout 65;
# 设置默认的索引文件
index index.html index.htm;
# 设置客户端请求体的最大大小
client_max_body_size 1000m;
# 设置客户端请求头的超时时间
client_header_timeout 15m;
# 设置客户端请求体的超时时间
client_body_timeout 15m;
# 设置代理连接的超时时间
proxy_connect_timeout 15s;
# 设置代理读取的超时时间
proxy_read_timeout 30m;
# 设置代理发送的超时时间
proxy_send_timeout 30m;
# 针对*.lingyanspace.com的HTTP配置
server {
listen 80;
listen [::]:80;
#请填写绑定证书的域名
server_name *.lingyanspace.com;
#把http的域名请求转成https
return 301 https://$host$request_uri;
}
# 针对*.lingyanspace.com的HTTPS配置
server {
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
server_name *.lingyanspace.com;
# SSL证书相关配置
ssl_certificate /etc/nginx/ssl/letsencrypt_cert/fullchain.pem;
ssl_certificate_key /etc/nginx/ssl/letsencrypt_cert/certkey.pem;
ssl_dhparam /etc/nginx/ssl/dhparam.pem;
# 配置SSL会话缓存
ssl_session_cache shared:SSL:10m;
# 配置SSL会话超时时间
ssl_session_timeout 10m;
# 配置SSL协议版本
ssl_protocols TLSv1.2 TLSv1.3;
# 配置SSL加密算法
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
# 关闭访问日志(可根据需求修改)
# access_log off;
# 此处可根据具体需求添加更多配置,如网站根目录、反向代理等
}
# 包含conf.d目录下的所有.http.conf文件
include conf.d/*.http.conf;
}
stream {
include conf.d/*.tcp.conf;
}
#rtmp {
# include conf.d/*.rtmp.conf;
#}