Skip to content

Instantly share code, notes, and snippets.

@gatespace
Last active July 15, 2016 03:00
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gatespace/5611265 to your computer and use it in GitHub Desktop.
Save gatespace/5611265 to your computer and use it in GitHub Desktop.
網元でWordPressの管理画面にアクセス制限(IP or Basic認証)をかける時に /etc/nginx/conf.d/default.conf に追記する内容
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