1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Apache2 で Basic認証

Last updated at Posted at 2020-06-28

Apache2.4 でBasic 認証をする方法です。
.htacess を使う方法です。

http://hostname/tmp/test にBasic 認証をかけるとすると、
サーバーの Root が /var/www であると、

/var/www/tmp/test/.htaccess
AuthUserFile /var/www/tmp/test/.htpasswd
AuthName "Basic Auth"
AuthType Basic
Require valid-user

パスワードの作成 ユーザーは scott

htpasswd -c .htpasswd scott

ブラウザーで、http://tmp/test にアクセスすると、

basic_jun29.png

.htacess を使わない時は、Apache2 の設定ファイルで

<Directory "/var/www/tmp/test">
	AuthUserFile /etc/apache2/.htpasswd
	AuthName "Basic Auth"
	AuthType Basic
	Require valid-user
</Directory>
1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?