-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx-wp.conf
140 lines (123 loc) · 3.61 KB
/
nginx-wp.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
## Cache
#open_file_cache max=1000 inactive=24h;
#open_file_cache_valid 24h;
#open_file_cache_min_uses 2;
#open_file_cache_errors on;
## Timeouts
client_header_timeout 15;
client_body_timeout 15;
send_timeout 15;
#keepalive_timeout 2 2;
## Size limits
client_max_body_size 15m;
client_header_buffer_size 32k;
client_body_buffer_size 128k;
large_client_header_buffers 64 8k;
## General
types_hash_max_size 2048;
server_names_hash_bucket_size 64;
ignore_invalid_headers on;
limit_conn_zone $binary_remote_addr zone=addr:10m;
recursive_error_pages on;
reset_timedout_connection on;
#sendfile on;
tcp_nopush on;
tcp_nodelay on;
server_tokens off;
server_name_in_redirect off;
keepalive_requests 100;
## Compression
gzip on;
gzip_static on;
gzip_comp_level 6;
gzip_disable "msie6";
gzip_buffers 32 8k;
gzip_vary on;
gzip_proxied any;
gzip_min_length 0;
gzip_http_version 1.0;
gzip_types text/css text/javascript text/xml text/plain application/javascript application/x-javascript application/json application/xml application/rss+xml;
output_buffers 10 128k;
postpone_output 1500;
## Fastcgi Caching
fastcgi_cache_path /var/cache/nginx/fastcgi_tmp levels=1:2
keys_zone=CZONE:15m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout invalid_header http_500;
server {
listen 80;
server_name localhost;
root /var/www/html;
index index.html index.htm index.php;
## Wordpress permalinks
location / {
try_files $uri $uri/ /index.php?$args;
}
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
#error_page 404 /404.html;
## Redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
## Proxy the PHP scripts to Apache listening on 127.0.0.1:80
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
## Deny access to hidden files
location ~ /\. {
deny all;
}
## Deny access to scripts in uploads folder
location ~* /(?:uploads|files)/.*\.php$ {
deny all;
}
## No log for known files
location ~* ^.+\.(js|css|swf|xml|ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|mid|midi|wav|bmp)$ {
access_log off; log_not_found off; expires 30d;
}
location = /favicon.ico {
access_log off; log_not_found off; expires 30d;
}
location = /robots.txt {
allow all; access_log off; log_not_found off; expires 30d;
}
## No caching for logged in users
set $no_cache 1;
if ($request_method = POST) {
set $no_cache 1;
}
if ($query_string != "") {
set $no_cache 1;
}
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
set $no_cache 1;
}
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
set $no_cache 1;
}
## Wordpress findout if request comming to HTTPS
set $is_https "$https";
if ($http_x_forwarded_proto = "https") {
set $is_https "ON";
}
## Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
try_files $uri = 404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 90;
fastcgi_read_timeout 90;
fastcgi_buffer_size 128k;
fastcgi_buffers 64 128k;
fastcgi_cache_bypass $no_cache;
fastcgi_no_cache $no_cache;
fastcgi_cache_valid any 1h;
fastcgi_cache CZONE;
fastcgi_param HTTPS $is_https;
include fastcgi_params;
}
}