Last active
July 15, 2016 03:00
-
-
Save gatespace/5611265 to your computer and use it in GitHub Desktop.
網元でWordPressの管理画面にアクセス制限(IP or Basic認証)をかける時に /etc/nginx/conf.d/default.conf に追記する内容
This file contains hidden or 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
server { | |
# (略) | |
location ~* /wp-login\.php|/wp-admin/((?!admin-ajax\.php).)*$ { | |
index index.php index.html index.htm; | |
# 許可するIPアドレスを記述 | |
allow 192.168.0.1; | |
deny all; | |
# Basic認証のメッセージ | |
auth_basic "Please enter your ID and password"; | |
# .htpasswd ファイルのパス | |
auth_basic_user_file /etc/nginx/conf.d/.htpasswd; | |
if ($request_filename ~ .*\.php) { | |
break; | |
proxy_pass http://backend; | |
} | |
include /etc/nginx/expires; | |
} | |
# (略) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment