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//查看功能模块配置
nginx -V
//检查系统的编译器、库和其他依赖是否存在,并配置编译选项
./configure
--prefix=/usr/share/nginx
--sbin-path=/usr/sbin/nginx
--modules-path=/usr/lib64/nginx/modules/ngx_http_image_filter_module.somodules
load_module--conf-path=/etc/nginx/nginx.conf
--error-log-path=/var/log/nginx/error.log
--http-log-path=/var/log/nginx/access.log
--http-client-body-temp-path=/var/lib/nginx/tmp/client_body
--http-proxy-temp-path=/var/lib/nginx/tmp/proxy
--http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi
--http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi
--http-scgi-temp-path=/var/lib/nginx/tmp/scgi
--pid-path=/run/nginx.pid
--lock-path=/run/lock/subsys/nginx
--user=nginx
--group=nginx
--with-compat
--with-debug
--with-file-aio
--with-http_addition_module
--with-http_auth_request_module
--with-http_dav_module
--with-http_degradation_module
--with-http_flv_module
--with-http_gunzip_module
--with-http_gzip_static_module
--with-http_image_filter_module=dynamic
--with-http_mp4_module
--with-http_perl_module=dynamic
--with-http_random_index_module
--with-http_realip_module
--with-http_secure_link_module
--with-http_slice_module
--with-http_ssl_module
--with-http_stub_status_module
--with-http_sub_module
--with-http_v2_module
--with-http_xslt_module=dynamic
--with-mail=dynamic
--with-mail_ssl_module
--with-pcre
--with-pcre-jit
--with-stream_ssl_module
--with-stream_ssl_preread_module
--with-stream
--with-threads
--with-cc-opt='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib64/nginx/modules/ngx_http_perl_module.solib/rpm/redhat/redhat-hardened-cc1 load_module-fstack-protector-strong -specs=/usr/lib64/nginx/modules/ngx_http_xslt_filter_module.solib/rpm/redhat/redhat-annobin-cc1 load_module-m64 -march=x86-64-v2 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' --with-ld-opt='-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib64/nginx/modules/ngx_mail_module.solib/rpm/redhat/redhat-hardened-ld load_module -specs=/usr/lib64/nginx/modules/ngx_stream_module.solib/rpm/redhat/redhat-annobin-cc1 #vod-Wl,-E'
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 --add-module=/home/lingyanspace/LimitVideo/;nginx-rtmp-module-master
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 =--add-module=/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;
}home/nginx-vod-module-master
//路径标识清理之前的编译结果
publicmake stringclean
LimitVideo//使用生成的Makefile来编译源代码。它会调用编译器和链接器,生成可执行文件和库
=make
"LimitVideo";//编译安装
publicmake string LimitFile = "LimitFile";
public string OpenFile = "OpenFile";install
生成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;1G;
# 配置FastCGI的缓冲区,使用64个4KB的缓冲区来缓存FastCGI的响应
fastcgi_buffers 64 4K;
# 设置客户端请求头的超时时间
client_header_timeout 15m;
# 设置客户端请求体的超时时间
client_body_timeout 15m;
# 设置代理连接的超时时间
proxy_connect_timeout 15s;
# 设置代理读取的超时时间
proxy_read_timeout 30m;
# 设置代理发送的超时时间
proxy_send_timeout 30m;
# 增加最大缓存条目至 2000,非活动时间为 10 分钟
open_file_cache max=2000 inactive=10m;
# 缓存有效性检查间隔增加至 4 分钟
open_file_cache_valid 4m;
# 最小使用次数增加至 2,以保持缓存条目
open_file_cache_min_uses 2;
# 缓存错误信息
open_file_cache_errors on;
# 启用异步 I/O
aio on;
#设置 Host 头为请求的主机名,不包括端口
proxy_set_header Host $host;
#将客户端的真实IP地址传递给后端服务器
proxy_set_header X-Real-IP $remote_addr;
#用于传递客户端的真实IP地址链,这对于需要追踪请求来源的后端服务尤其重要
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#传递请求的协议(HTTP或HTTPS)给后端服务器
proxy_set_header X-Forwarded-Proto $scheme;
# 针对*.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;
#}