附上本人配置文件。
#user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 600;
client_max_body_size 128m;
server_names_hash_bucket_size 64;
fastcgi_connect_timeout 300s;
fastcgi_send_timeout 300s;
fastcgi_read_timeout 300s;
fastcgi_buffer_size 128k;
fastcgi_buffers 8 128k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;
gzip on;
gzip_comp_level 9;
gzip_types text/plain text/css application/javascript;
server {
listen 80;
return 403;
}
server {
listen 80;
server_name loli.wiki www.loli.wiki
loliwiki.cn www.loliwiki.cn loliwiki.cc www.loliwiki.cc loliwiki.org www.loliwiki.org;
return 301
https://www.loliwiki.org$request_uri;
}
server {
listen 443 ssl http2;
server_name
www.loliwiki.org;
index index.php index.htm index.html;
root /var/www/wiki;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_certificate /usr/local/nginx/conf/1.crt;
ssl_certificate_key /usr/local/nginx/conf/1.key;
ssl_ct on;
ssl_ct_static_scts /usr/local/nginx/conf/sct1;
location / {
try_files $uri $uri/ /index.php?$args;
if (-f $request_filename) {
break;
}
set $supercache_file '';
set $supercache_uri $request_uri;
set $supercache 1;
set $ihttp_host '';
if ($request_method = POST) {
set $supercache 0;
}
set $qs 0;
if ($query_string) {
set $qs 1;
}
if ($query_string ~* "^utm_source=([^&]+)&utm_medium([^&]+)&utm_campaign=([^&]+)(&utm_content=([^&]+))?$") {
set $qs 0;
set $supercache_uri $document_uri;
}
#deactivate on high load
if ($qs = 1) {
set $supercache 0;
}
if ($http_cookie ~* "comment_author_|wordpress|wp-postpass_" ) {
set $supercache 0;
}
if ($http_user_agent ~* '(iphone|ipod|aspen|incognito|webmate|android|dream|cupcake|froyo|blackberry9500|blackberry9520|blackberry9530|blackberry9550|blackberry 9800|webos|s8000|bada)') {
set $ihttp_host '-mobile';
}
if ($supercache = 0) {
set $supercache_uri '';
}
if ($supercache_uri ~ ^(.+)$) {
set $supercache_file /var/www/html/wp-content/cache/supercache/$http_host$1/index${ihttp_host}.html;
}
if (-f $document_root$supercache_file) {
#rewrite ^(.*)$ $supercache_file break;
rewrite ^ $supercache_file last;
}
if (!-e $request_filename) {
rewrite . /index.php last;
}
}
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
location ~ /\.ht {
deny all;
}
location ~ \.(gif|jpg|png|htm|html|css|js|ico)$ {
expires 30d;
}
location ~ .*\.(php|php5)?$ {
fastcgi_pass unix:/var/run/phpfpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
}
server {
listen 80;
server_name
hardware.name www.hardware.name hardwareunion.com;
return 301
http://www.hardwareunion.com$request_uri;
}
server {
listen 80;
server_name
www.hardwareunion.com;
index index.php index.htm index.html;
root /var/www/html;
location / {
try_files $uri $uri/ /index.php?$args;
if (-f $request_filename) {
break;
}
set $supercache_file '';
set $supercache_uri $request_uri;
set $supercache 1;
set $ihttp_host '';
if ($request_method = POST) {
set $supercache 0;
}
set $qs 0;
if ($query_string) {
set $qs 1;
}
if ($query_string ~* "^utm_source=([^&]+)&utm_medium([^&]+)&utm_campaign=([^&]+)(&utm_content=([^&]+))?$") {
set $qs 0;
set $supercache_uri $document_uri;
}
#deactivate on high load
if ($qs = 1) {
set $supercache 0;
}
if ($http_cookie ~* "comment_author_|wordpress|wp-postpass_" ) {
set $supercache 0;
}
if ($http_user_agent ~* '(iphone|ipod|aspen|incognito|webmate|android|dream|cupcake|froyo|blackberry9500|blackberry9520|blackberry9530|blackberry9550|blackberry 9800|webos|s8000|bada)') {
set $ihttp_host '-mobile';
}
if ($supercache = 0) {
set $supercache_uri '';
}
if ($supercache_uri ~ ^(.+)$) {
set $supercache_file /var/www/html/wp-content/cache/supercache/$http_host$1/index${ihttp_host}.html;
}
if (-f $document_root$supercache_file) {
#rewrite ^(.*)$ $supercache_file break;
rewrite ^ $supercache_file last;
}
if (!-e $request_filename) {
rewrite . /index.php last;
}
}
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
location ~ /\.ht {
deny all;
}
location ~ \.(gif|jpg|png|htm|html|css|js|ico)$ {
expires 30d;
}
location ~ .*\.(php|php5)?$ {
fastcgi_pass unix:/var/run/phpfpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
}
}