詳しくは上記を。
server {
listen 80;
# アクセス可能なIPアドレス、もしくはドメイン
server_name 192.168.11.27;
root /var/www/html;
index index.html;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_max_temp_file_size 0;
sendfile off;
etag off;
if_modified_since off;
location / {
expires -1;
proxy_pass http://localhost:8000;
}
}
server {
listen 8000;
server_name localhost;
root /var/www/html;
index index.html;
add_header Cache-Control no-cache;
sendfile off;
etag off;
if_modified_since off;
}
server {
add_header Cache-Control no-cache; #※CDNの種類によってはno-cacheをprivateに変える必要がある。
※略
location / {
# disable cache
expires -1;
proxy_pass http://127.0.0.1:80;
}
location /no-cache/ {
※略
add_header Cache-Control no-cache; #※CDNの種類によってはno-cacheをprivateに変える必要がある。
proxy_no_cache 1;
proxy_cache_bypass 1;
sendfile off;
etag off;
if_modified_since off;
※略
}
※略
## WordPress キャッシュ設定
# 初期値をキャッシュするに設定
set $do_not_cache 0;
## 直接.phpの拡張子のあるものはキャッシュしない。
#if ($uri ~* "\.php$") {
# set $do_not_cache 1;
#}
# GET以外はキャッシュしない
if ($request_method != "GET") {
set $do_not_cache 1;
}
# POSTはキャッシュしない
if ($request_method = POST) {
set $do_not_cache 1;
}
# WordPress特有のURLやファイルをキャッシュしない
if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
set $do_not_cache 1;
}
# WordPressログイン中や、コメントした人はキャッシュしない
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
set $do_not_cache 1;
}
## WordPress キャッシュ設定 ここまで
※略
}#server

![[Solved] Nginx 空のファイルがダウンロードされる nginx empty file download](https://www.yuulinux.tokyo/contents/wp-content/uploads/2022/04/Nginx_logo.svg_-150x150.png)
![【Soved】Nginx [crit] 20655#20655: *56 open() “/var/log/nginx/xxxx.access.log” failed (13: Permission denied) while logging request](https://www.yuulinux.tokyo/contents/wp-content/uploads/2020/06/linux_2021_2-150x150.jpg)
