57
52

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 5 years have passed since last update.

AWS EC2 Amazon Linux + ApacheでBasic認証

Posted at

EC2でテスト環境とかまだ公開したくないアプリケーションを作成した時に、簡単な認証をかけたくなることがよくある。
ってことで AWS EC2 Amazon Linux + Apache 環境でBasic認証のかけ方

##認証ユーザの作成、追加
認証に使用したいユーザのログイン名とパスワードを.htpasswdファイルに設定する

htpasswd -c -b /etc/httpd/conf/.htpasswd user1 password

##Basic認証を有効にする
最終行にBasic認証の設定を追加する

vi /etc/httpd/conf/httpd.conf

<Directory "/var/www/html/">
AuthUserFile /etc/httpd/conf/.htpasswd
AuthGroupFile /dev/null
AuthName "Basic Auth"
AuthType Basic
Require valid-user
</Directory>

Apacheの再起動をして設定完了

/etc/init.d/httpd restart
57
52
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
57
52

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?