Nginxを利用したBasic Auth(認証)の設定をしてみます。

[root@nginx01 ~]# yum install httpd-tools
読み込んだプラグイン:product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
インストール処理の設定をしています
rhel-dvd                                                 | 4.1 kB     00:00 ...
パッケージ httpd-tools-2.2.15-45.el6.x86_64 はインストール済みか最新バージョンです
何もしません


まずはhttpd-toolsパッケージがインストールされているかを確認します。
今回の環境ではインストールされていました。

[root@nginx01 ~]# htpasswd -c /etc/nginx/.htpasswd username
New password:
Re-type new password:
Adding password for user username


htpasswdコマンドを利用し、パスワードファイルを作成します。

[root@nginx01 ~]# vi /etc/nginx/nginx.conf



                location / {
                        auth_basic "Restricted";
                        auth_basic_user_file /etc/nginx/.htpasswd;


作成したパスワードファイルを設定ファイル内で指定します。

basic_auth

ブラウザでアクセスし、認証ダイアログが表示されることを確認しました。