質問編集履歴
2
codeの削除
test
CHANGED
File without changes
|
test
CHANGED
@@ -37,425 +37,3 @@
|
|
37
37
|
http://www.yukihirai0505.com:9000/play/
|
38
38
|
|
39
39
|
と80以外のポートを指定すれば立ち上がります。
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
default.conf
|
44
|
-
|
45
|
-
```
|
46
|
-
|
47
|
-
# ドキュメントルート
|
48
|
-
|
49
|
-
root /var/www/html/;
|
50
|
-
|
51
|
-
# インデックスファイル指定
|
52
|
-
|
53
|
-
index index.php index.html index.htm;
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
# キャッシュしたファイルが保管されるパスと、キャッシュゾーンの名前、容量を指定
|
58
|
-
|
59
|
-
#「cache1」のプロキシキャッシュ保管場所として「/var/cache/nginx/cache1」を指定
|
60
|
-
|
61
|
-
#「keys_zone=cache1:128m」でその容量は128MB
|
62
|
-
|
63
|
-
#「levels=1」でキャッシュをファイルで格納する際にキーを1階層のディレクトリごとに分けて格納
|
64
|
-
|
65
|
-
proxy_cache_path /var/cache/nginx/cache1 levels=1 keys_zone=cache1:128m;
|
66
|
-
|
67
|
-
# 利用するキャッシュゾーンの名前を指定
|
68
|
-
|
69
|
-
proxy_cache cache1;
|
70
|
-
|
71
|
-
proxy_set_header Host $host;
|
72
|
-
|
73
|
-
proxy_set_header X-Real-IP $remote_addr;
|
74
|
-
|
75
|
-
proxy_set_header X-Forwarded-Host $host;
|
76
|
-
|
77
|
-
proxy_set_header X-Forwarded-Server $host;
|
78
|
-
|
79
|
-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
80
|
-
|
81
|
-
# ステータスコードが通常応答の「200」と、ファイルが存在しない「404」の場合30分間キャッシュを保持
|
82
|
-
|
83
|
-
proxy_cache_valid 200 404 30m;
|
84
|
-
|
85
|
-
# プロキシサーバ設定
|
86
|
-
|
87
|
-
server {
|
88
|
-
|
89
|
-
listen 80 default_server;
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
# ドットファイルへのアクセスを禁止、ログへの記録オフ
|
94
|
-
|
95
|
-
location ~ /\. {deny all; access_log off; log_not_found off; }
|
96
|
-
|
97
|
-
# robots.txt へのアクセスはログへの記録オフ
|
98
|
-
|
99
|
-
location = /robots.txt { access_log off; log_not_found off; }
|
100
|
-
|
101
|
-
# favicon へのアクセスはログへの記録オフ
|
102
|
-
|
103
|
-
location = /favicon.ico { access_log off; log_not_found off; }
|
104
|
-
|
105
|
-
# JavaScript CSS 画像へのアクセスはログへの記録オフ、直ちにプロキシに通しキャッシュ。
|
106
|
-
|
107
|
-
# この期の設定でアクセス元の状態で複数キャッシュを行うが画像ファイルなどは複数キャッシュさせない
|
108
|
-
|
109
|
-
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
|
110
|
-
|
111
|
-
log_not_found off;
|
112
|
-
|
113
|
-
proxy_pass http://unix:/var/run/nginx.sock;
|
114
|
-
|
115
|
-
}
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
# プロキシキャッシュ設定
|
120
|
-
|
121
|
-
# 初期値はキャッシュするにセット
|
122
|
-
|
123
|
-
set $do_not_cache 0;
|
124
|
-
|
125
|
-
# .php ファイルへ直接アクセスがあるのは基本的に管理ページのみのためキャッシュしない
|
126
|
-
|
127
|
-
if ($uri ~* "\.php$") {
|
128
|
-
|
129
|
-
set $do_not_cache 1;
|
130
|
-
|
131
|
-
}
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
# POST 時はキャッシュしない
|
136
|
-
|
137
|
-
if ($request_method = POST) {
|
138
|
-
|
139
|
-
set $do_not_cache 1;
|
140
|
-
|
141
|
-
}
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
# $proxy_cache_key に任意の文字を加えることで別のキーでページをキャッシュ可能にする
|
146
|
-
|
147
|
-
set $proxy_cache_key "$scheme://$host$request_uri";
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
# ログイン状態またはコメントを記入したことがあれば、その情報ごとにキャッシュを分ける
|
152
|
-
|
153
|
-
if ($http_cookie ~ "(wordpress_logged_in_|comment_author_)(.*)") {
|
154
|
-
|
155
|
-
set $proxy_cache_key "$2::$proxy_cache_key";
|
156
|
-
|
157
|
-
}
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
# 今まで組み立てたプロキシ設定でキャッシュを実行
|
162
|
-
|
163
|
-
location / {
|
164
|
-
|
165
|
-
proxy_no_cache $do_not_cache;
|
166
|
-
|
167
|
-
proxy_cache_bypass $do_not_cache;
|
168
|
-
|
169
|
-
proxy_cache_key $proxy_cache_key;
|
170
|
-
|
171
|
-
proxy_pass http://unix:/var/run/nginx.sock;
|
172
|
-
|
173
|
-
}
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
}
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
# ウェブサーバ設定
|
182
|
-
|
183
|
-
server {
|
184
|
-
|
185
|
-
# ポートを指定
|
186
|
-
|
187
|
-
#listen 80;
|
188
|
-
|
189
|
-
listen unix:/var/run/nginx.sock;
|
190
|
-
|
191
|
-
# 実ファイルがない場合のアクセスファイル
|
192
|
-
|
193
|
-
try_files $uri $uri/ /index.php;
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
location / {
|
198
|
-
|
199
|
-
# WordPress パーマリンク設定を利用可能にする
|
200
|
-
|
201
|
-
if (!-e $request_filename) {
|
202
|
-
|
203
|
-
rewrite ^.+?(/wp-.*) $1 last;
|
204
|
-
|
205
|
-
rewrite ^.+?(/.*\.php)$ $1 last;
|
206
|
-
|
207
|
-
# ドキュメントルートから WordPress までの相対パス
|
208
|
-
|
209
|
-
# (ドキュメントルートにインストールしたため相対パスは記入なし)
|
210
|
-
|
211
|
-
rewrite ^ /index.php last;
|
212
|
-
|
213
|
-
}
|
214
|
-
|
215
|
-
}
|
216
|
-
|
217
|
-
# WP Super Cache rules.
|
218
|
-
|
219
|
-
gzip_static on;
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
set $supercacheuri "";
|
224
|
-
|
225
|
-
set $supercachefile "$document_root/wp-content/cache/supercache/${http_host}${uri}index.html";
|
226
|
-
|
227
|
-
if (-e $supercachefile) {
|
228
|
-
|
229
|
-
set $supercacheuri "/wp-content/cache/supercache/${http_host}${uri}index.html";
|
230
|
-
|
231
|
-
}
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
# If this is a POST request, pass the request onto WordPress.
|
236
|
-
|
237
|
-
if ($request_method = POST) {
|
238
|
-
|
239
|
-
set $supercacheuri "";
|
240
|
-
|
241
|
-
}
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
# If there is a query string, serve the uncached version.
|
246
|
-
|
247
|
-
if ($query_string) {
|
248
|
-
|
249
|
-
set $supercacheuri "";
|
250
|
-
|
251
|
-
}
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
# Logged in users and those who have posted a comment get the non-cached version.
|
260
|
-
|
261
|
-
if ($http_cookie ~* comment_author_|wordpress_logged_in|wp-postpass_) {
|
262
|
-
|
263
|
-
set $supercacheuri "";
|
264
|
-
|
265
|
-
}
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
# Stop processing if the supercache file is valid.
|
274
|
-
|
275
|
-
if ($supercacheuri) {
|
276
|
-
|
277
|
-
rewrite ^ $supercacheuri break;
|
278
|
-
|
279
|
-
}
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
location ~* \.(txt|html?|js|css)$ {
|
284
|
-
|
285
|
-
expires 30d;
|
286
|
-
|
287
|
-
}
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
location ~* \.(png|jpe?g|gif|ico)$ {
|
292
|
-
|
293
|
-
expires 365d;
|
294
|
-
|
295
|
-
}
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
# PHP-FPM 設定
|
300
|
-
|
301
|
-
location ~ \.php$ {
|
302
|
-
|
303
|
-
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
|
304
|
-
|
305
|
-
fastcgi_index index.php;
|
306
|
-
|
307
|
-
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
308
|
-
|
309
|
-
include fastcgi_params;
|
310
|
-
|
311
|
-
}
|
312
|
-
|
313
|
-
}
|
314
|
-
|
315
|
-
```
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
nginx.conf
|
320
|
-
|
321
|
-
```
|
322
|
-
|
323
|
-
user nginx;
|
324
|
-
|
325
|
-
worker_processes 2;
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
error_log /var/log/nginx/error.log warn;
|
330
|
-
|
331
|
-
pid /var/run/nginx.pid;
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
events {
|
338
|
-
|
339
|
-
worker_connections 1024;
|
340
|
-
|
341
|
-
use epoll;
|
342
|
-
|
343
|
-
}
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
http {
|
350
|
-
|
351
|
-
include /etc/nginx/mime.types;
|
352
|
-
|
353
|
-
default_type application/octet-stream;
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
358
|
-
|
359
|
-
'$status $body_bytes_sent "$http_referer" '
|
360
|
-
|
361
|
-
'"$http_user_agent" "$http_x_forwarded_for" $request_time';
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
access_log /var/log/nginx/access.log main;
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
sendfile on;
|
370
|
-
|
371
|
-
tcp_nopush on;
|
372
|
-
|
373
|
-
tcp_nodelay on;
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
keepalive_timeout 10;
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
connection_pool_size 256;
|
382
|
-
|
383
|
-
client_header_buffer_size 1k;
|
384
|
-
|
385
|
-
large_client_header_buffers 4 2k;
|
386
|
-
|
387
|
-
request_pool_size 4k;
|
388
|
-
|
389
|
-
if_modified_since before;
|
390
|
-
|
391
|
-
ignore_invalid_headers on;
|
392
|
-
|
393
|
-
server_tokens off;
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
# 静的な gzip ファイルがある場合はそれを参照
|
398
|
-
|
399
|
-
gzip_static on;
|
400
|
-
|
401
|
-
output_buffers 1 32k;
|
402
|
-
|
403
|
-
postpone_output 1460;
|
404
|
-
|
405
|
-
gzip on;
|
406
|
-
|
407
|
-
gzip_min_length 0;
|
408
|
-
|
409
|
-
gzip_buffers 4 8k;
|
410
|
-
|
411
|
-
gzip_http_version 1.0;
|
412
|
-
|
413
|
-
gzip_types text/plain
|
414
|
-
|
415
|
-
text/xml
|
416
|
-
|
417
|
-
text/css
|
418
|
-
|
419
|
-
application/xml
|
420
|
-
|
421
|
-
application/xhtml+xml
|
422
|
-
|
423
|
-
application/rss+xml
|
424
|
-
|
425
|
-
application/atom_xml
|
426
|
-
|
427
|
-
application/javascript
|
428
|
-
|
429
|
-
application/x-javascript
|
430
|
-
|
431
|
-
application/x-httpd-php;
|
432
|
-
|
433
|
-
# gzip 非対象。IE 1 から 6、Netscape 4
|
434
|
-
|
435
|
-
gzip_disable "MSIE [1-6]\.";
|
436
|
-
|
437
|
-
gzip_disable "Mozilla/4";
|
438
|
-
|
439
|
-
gzip_comp_level 1;
|
440
|
-
|
441
|
-
gzip_proxied any;
|
442
|
-
|
443
|
-
gzip_vary on;
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
# fastcgi cacheの設定(httpディレクティブ内のみ有効)
|
448
|
-
|
449
|
-
fastcgi_cache_path /var/cache/nginx/cache levels=1:2 keys_zone=wpcache:10m max_size=50M inactive=30m;
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
include /etc/nginx/conf.d/*.conf;
|
454
|
-
|
455
|
-
}
|
456
|
-
|
457
|
-
```
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
```
|
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -32,6 +32,14 @@
|
|
32
32
|
|
33
33
|
|
34
34
|
|
35
|
+
ちなみにVPS上で
|
36
|
+
|
37
|
+
http://www.yukihirai0505.com:9000/play/
|
38
|
+
|
39
|
+
と80以外のポートを指定すれば立ち上がります。
|
40
|
+
|
41
|
+
|
42
|
+
|
35
43
|
default.conf
|
36
44
|
|
37
45
|
```
|