Skip to content

Instantly share code, notes, and snippets.

@wokamoto
Last active December 15, 2021 04:39
Show Gist options
  • Save wokamoto/b9eb0f22d9948a38544d to your computer and use it in GitHub Desktop.
Save wokamoto/b9eb0f22d9948a38544d to your computer and use it in GitHub Desktop.
[Nginx][WordPress] Nginx で WordPress の管理画面に BASIC 認証をかける ( ただし /wp-admin/admin-ajax.php, /wp-admin/css/*, /wp-admin/js/* にはかけない )
location ~* /wp-login\.php|/wp-admin/((?!(admin-ajax\.php|css/|js/)).)*$ {
index index.php index.html index.htm;
# Basic認証のメッセージ
auth_basic "Please enter your ID and password";
# .htpasswd ファイルのパス
auth_basic_user_file /etc/nginx/conf.d/.htpasswd;
location ~ .*\.php$ {
try_files $uri =404;
proxy_pass http://backend;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment