LoginSignup
14
5

More than 3 years have passed since last update.

Nginxでbotからのアクセス時にBasic認証を外す

Last updated at Posted at 2015-12-03

公開前で認証かけときたいけどOGPのチェックはしたいときに

server {
  set $auth "Restricted";
  if ($http_user_agent ~ (Twitterbot|facebookexternalhit)) {
    set $auth off;
  }

  location / {
    auth_basic $auth;
    auth_basic_user_file /etc/nginx/.htpasswd;
  }
}
14
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
5