Last active
January 2, 2019 11:37
-
-
Save a-yasui/998897944681e2334093f95bfed8a0a0 to your computer and use it in GitHub Desktop.
I use the word press at nginx + php-fpm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Directory List: | |
# | |
# /srv/www <- base | |
# /srv/www/webpage <- root directory | |
# /srv/www/pages/40x.html <- 40x error page | |
# /srv/www/pages/50x.html <- 50x server error page | |
# | |
server { | |
listen 80; | |
listen [::]:80; | |
server_name _; | |
root /srv/www/webpage; | |
gzip on; | |
gzip_min_length 1024; | |
gzip_buffers 4 8k; | |
gzip_http_version 1.0; | |
gzip_comp_level 2; | |
gzip_vary on; | |
gzip_proxied any; | |
gzip_types text/plain text/css application/javascript | |
text/xml application/atom+xml application/xml+rss | |
application/json text/json text/javascript+json | |
application/x-javascript; | |
gzip_disable "MSIE [1-6]."; | |
gzip_disable "Mozilla/4"; | |
add_header Strict-Transport-Security "max-age=15552000; includeSubDomains"; | |
add_header X-Content-Type-Options nosniff; | |
add_header X-Frame-Options "SAMEORIGIN"; | |
add_header X-XSS-Protection "1; mode=block"; | |
add_header X-Robots-Tag all; | |
add_header X-Download-Options noopen; | |
add_header X-Permitted-Cross-Domain-Policies none; | |
# */wp-admin へのリクエスト末尾にスラッシュを追加します。 | |
rewrite /wp-admin$ $scheme://$host$uri/ permanent; | |
# 一般的な制限設定のファイル。 | |
# どの server {} ブロックからもインクルードできるよう設計されています。 | |
location = /favicon.ico { | |
log_not_found off; | |
access_log off; | |
} | |
location = /robots.txt { | |
allow all; | |
log_not_found off; | |
access_log off; | |
} | |
# .htaccess, .htpasswd, .DS_Store (Mac)といった隠しファイルへのアクセスを拒否します。 | |
location ~ /\. { | |
deny all; | |
access_log off; | |
log_not_found off; | |
} | |
location / { | |
index index.php index.html; | |
# この命令文は奇妙に見えるかもしれません。これは以下のルールすべてが失敗したときにマッチを試みます。 | |
# http://wiki.nginx.org/HttpCoreModule | |
try_files $uri $uri/ /index.php?$args; | |
location ~* (.*\.php)$ { | |
try_files $uri = 404; | |
fastcgi_split_path_info ^(.+\.php)(.*)$; | |
include fastcgi_params; | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_pass 127.0.0.1:9000; | |
} | |
location ~* \.(?:css|js)$ { | |
add_header Cache-Control "max-age=15778463"; | |
add_header Strict-Transport-Security "max-age=15552000; includeSubDomains"; | |
add_header X-Content-Type-Options nosniff; | |
add_header X-Frame-Options "SAMEORIGIN"; | |
add_header X-XSS-Protection "1; mode=block"; | |
add_header X-Robots-Tag all; | |
add_header X-Download-Options noopen; | |
add_header X-Permitted-Cross-Domain-Policies none; | |
} | |
location ~* \.(?:jpg|JPG|jpeg|JEPG|png|PNG)$ { | |
gzip_static on; | |
expires 1d; | |
} | |
} | |
error_page 404 /404.html; | |
location = /srv/www/pages/40x.html { | |
} | |
error_page 500 502 503 504 /50x.html; | |
location = /srv/www/pages/50x.html { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment