ラベル nginx の投稿を表示しています。 すべての投稿を表示
ラベル nginx の投稿を表示しています。 すべての投稿を表示

2014年12月27日土曜日

MacにAWS-ElasticBeanstalkコマンドコマンドツールをインストールする方法


AWS-ElasticBeanstalkコマンドコマンドツールをインストールする方法のメモです。

zipのダウンロード

cd ~/Workspaces/aws/Elastic-Beanstalk/
curl https://s3.amazonaws.com/elasticbeanstalk/cli/AWS-ElasticBeanstalk-CLI-2.2.zip -o AWS-ElasticBeanstalk-CLI-2.2.zip

zipの解凍

unzip AWS-ElasticBeanstalk-CLI-2.2.zip

bashrcに環境変数を追加

echo 'export PATH="$HOME/Workspaces/aws/Elastic-Beanstalk/AWS-ElasticBeanstalk-CLI-2.2/eb/macosx/python2.7:$PATH"' >> ~/.bashrc

bashrcのリロード

source ~/.bashrc

確認

eb --help

ヘルプが表示されれば成功。

2014年12月4日木曜日

NginxにBasic認証を設定する

nginx.confの設定

nginx.confに以下を追加
server {
    listen       80;
    server_name  www.sample.com;

    ## ここから 追加
    auth_basic "please login test";
    auth_basic_user_file "/etc/nginx/authfiles/.basicauthpasswd";
    ## ここまで 追加
    ・・・・

パスワードファイルの作成

パスワードの作成には、htpasswd コマンドを使用します。

新規に作成する場合

以下を実行して、作成されたファイル(.basicauthpasswd)を
/etc/nginx/authfiles/配下に設置します。
htpasswd -bc .basicauthpasswd testuser testpassword

複数ユーザーを追加する場合

htpasswd -bn testuser2 testpassword2
とすると、下記のような結果が帰ってくるので、
これを、.basicauthpasswdファイル内に追加で記述すればOKです。
testuser2:$apr1$inx7Pllo$fqPEAt0uwgBxwxGe5/35v0

htpasswd

呼び出しは下記の通りです。
htpasswd -b[cmdpsD] passwordfile username password

htpasswdのオプション

オプション 説明
-c 新しいパスワードファイルを作成します。もし、同名のパスワードファイルがすでに存在する場合は、既存の内容が削除されます。
-n どのような結果になるかのみを標準出力して終了します。パスワードファイルを変更しません(テスト実行用)。
-m パスワードをファイルに書き込む際、MD5 でハッシュします。
-d パスワードをファイルに書き込む際、CRYPT でハッシュします(デフォルト)。
-p パスワードをファイルに書き込む際、ハッシュしないで、プレーンなテキストのまま書き込みます。
-s パスワードをファイルに書き込む際、SHA でハッシュします。
-b パスワードを、対話式入力ではなくて、コマンドライン引数として指定できるようにします。

Nginxをリロード

/etc/init.d/nginx configtest
を実行して、以下のようにOKであれば
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
下記を実行。
/etc/init.d/nginx reload

statistics