Nginx配置文件模板
- nginx配置支持https 80端口访问自动跳转443
- 配置禁止脚本文件访问指定目录
- 配置目录自动按日期分割
server{
listen 80;
server_name server_name 52qcg.cn www.52qcg.cn;
rewrite ^(.*)$ https:
location / {
index index.shtml index.htm index.php index.html;
}
}
server {
listen 443;
server_name 52qcg.cn www.52qcg.cn;
index index.shtml index.htm index.php index.html;
root /data/www/cmmblog/public;
ssl on;
ssl_certificate cert/3086423_52qcg.cn.pem;
ssl_certificate_key cert/3086423_52qcg.cn.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location ~ /(wp-content|upload|wp-includes|images)/.*\.php$ { deny all; }
include enable-php.conf;
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
}
location /nginx_status
{
stub_status on;
access_log off;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /.well-known {
allow all;
}
location ~ /\.
{
deny all;
}
if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})")
{
set $year $1;
set $month $2;
set $day $3;
set $hour $4;
set $minutes $5;
set $seconds $6;
}
access_log /home/wwwlogs/cmmblog/cmmblog_access_$year$month$day.log;
}