Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
網元で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
You can’t perform that action at this time.