forked from wp-plugins/wp-ffpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx-template.conf
90 lines (72 loc) · 1.63 KB
/
nginx-template.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
server {
server_name example.com *.example.com;
root /home/serg/Sites/n/example.com;
index index.php;
access_log /var/log/nginx/example.com.access.log timed_combbined buffer=10k;
error_log /var/log/nginx/example.com.error.log;
default_type text/html;
set $memcached_raw_key $scheme://$host$request_uri;
set $memcached_key examplecom-data-$memcached_raw_key;
set $memcached_request 1;
if ($request_method = POST ) {
set $memcached_request 0;
}
if ($uri ~ "/wp-") {
set $memcached_request 0;
}
if ($args) {
set $memcached_request 0;
}
if ($http_cookie ~* "comment_author_|wordpressuser_|wp-postpass_|wordpress_logged_in_" ) {
set $memcached_request 0;
}
location ~ ^/(wp-login|xmlrpc)\.php {
deny all;
}
location ~* \.(?:ico|css|js|gif|jpe?g|png|svg|otf|ttf)$ {
expires 30d;
add_header Vary Accept-Encoding;
access_log off;
}
#
# php files
#
location ~ \.php$ {
include fastcgi.conf;
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_pass php-fpm;
}
location @php {
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
fastcgi_param SCRIPT_NAME /index.php;
include fastcgi_params;
fastcgi_pass php-fpm;
}
location / {
#
# first check memcached
#
if ($memcached_request = 1) {
memcached_pass memcached;
error_page 404 = @fallback;
}
#
# check files
#
try_files $uri $uri/ @php;
}
#
# second check files exists
#
location @fallback {
try_files $uri $uri/ @php;
}
if ($host ~* www\.(.*)) {
set $new_host $1;
rewrite ^(.*)$ http://$new_host$1 permanent;
}
if ($host != $server_name) {
rewrite ^(.*)$ http://$server_name$uri permanent;
}
}