一、/etc/nginx/nginx.conf文件
user nginx; #uedbet官网手机版最新用户
worker_processes 1; #允许进程数cpu * 核数 或者一般为 4/8,默认uedbet官网手机版最新 1
error_log /var/log/nginx/error.log; #错误日志 error PATH [ debug | info | notice | warn | error | crit ]
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
pid /var/run/nginx.pid; #进程号存放位置
worker_rlimit_nofile 65535; #一个nginx进程打开的最多文件描述符数目
events {
use epoll; #使用哪种事件模型:nginx 编译时 对内核版本高于 2.6.18的版本
multi_accept on; #nginx得到一个新连接时,接收尽可能多的连接
worker_connections 65535; #worker进程最大打开连接数ulimit -n
}
http {
client_body_timeout 1s; #用户请求体超时时间
client_max_body_size 12m; #判断请求体 Content-Length来判断请求体大小是否超过uedbet官网手机版最新值
include mime.types; #引入MIME类型
deny ip; #拒绝的IP(IP黑名单)
allow ip; #允许的IP(IP白名单)
default_type application/octet-stream; #设置默认MIME类型
server_tokens off; #关闭在错误页面以及服务器头部输出nginx 版本信息
log_format main '$remote_addr - $uri - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'; #日志格式
#access_log logs/access.log main;
access_log /var/log/nginx/access.log main; #请求日志
sendfile on; #是否开启高效文件传输模式
sendfile_max_chunk 100k; #每个进程每次调用传输数量的值不能大于设定值
tcp_nopush on; #告诉nginx在一个数据包里发送所有头文件,而不是一个一个发送,仅对 sendfile 有效
#keepalive_timeout 0;
keepalive_timeout 65 20; #设置与客户端长连接的超时时间
#limit_req_log_level warn; #设置延时消息日志级别
#limit_req_zone $binary_remote_addr zone=reqPerIp:10m rate=5r/s; #设置请求地址会话存储区域
#limit_conn_zone $binary_remote_addr zone=perip:10m; #储存会话状态,用于限制用户并发连接数
#gzipuedbet官网手机版最新;
gzip on;
gzip_http_version 1.0; #对指定的HTTP请求协议版本进行压缩
gzip_disable "MSIE [1-6]."; #对一些特定的用户代理不使用压缩
gzip_types text/plain application/x-javascript text/css text/javascriptimage/jpeg image/gif image/png;
gzip_min_length 1024; #设置响应体的最小长度
gzip_comp_level 3; #设定压缩级别1-9;1-最小压缩率,最快;9-最大压缩率,最慢,占用CPU资源最大
gzip_vary on; #设定是否响应数据包添加 Vary:Accept-Encoding HTTP 头(header)
# Load config files from the /etc/nginx/conf.d directory
# The default server is in conf.d/default.conf
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
proxy_hide_header 'Sec-Fetch-Dest';
proxy_hide_header 'Sec-Fetch-Mode';
proxy_hide_header 'Sec-Fetch-Site';
include /etc/nginx/conf.d/*.conf;
}
二、/etc/nginx/conf.d/*.conf(站点uedbet官网手机版最新文件)
server {
listen 80;
server_name domain.com;
rewrite ^/([a-z0-9/]+)?$ https://www.host.com/index.php?s=$1 break;
root dir_path;
location / {
index index.html index.htm index.php;
}
location ~.*\.(php)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
include /etc/nginx/fastcgi.conf;
}
}
server {
listen 443 ssl;
server_name skyshappiness.com www.skyshappiness.com blog.skyshappiness.com;
client_max_body_size 10m;
client_body_buffer_size 10m;
ssl_certificate "/etc/nginx/ssl/xxxxx/ssl.cert";
ssl_certificate_key "/etc/nginx/ssl/xxxxxx/ssl.key";
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers "EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5";
ssl_session_cache builtin:1000 shared:SSL:10m;
root dir_path;
location / {
index index.html index.htm index.php;
}
location ~.*\.(php)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
include /etc/nginx/fastcgi.conf;
}
}