Help us understand the problem. What is going on with this article?

Basic認証を付け加える一手間を最速で

More than 3 years have passed since last update.

Webページやサービスを作ってそれを顧客に見せる際に、一時的だけど一応Basic認証だけでもかけておきたい、という場合があると思います。
簡単な事なんだけど、なんだかんだ30分くらいかかってしまった、なんてことありませんか。
その手間を出来るだけ無くしたい。

ということで、簡単ではありますが、nginxにbasic認証をさせて、認証が通ったら、バックエンドサーバーに通信を流す、というDockerイメージを作成しました。

Docker Hub
GitHub

インストール

docker pull keisato/nginx-basic-auth-proxy
docker tag keisato/nginx-basic-auth-proxy nginx-basic-auth-proxy

基本的な使い方

# pseudo back end server (whatever you want)
docker run --name nginx -d nginx

# launch basic auth proxy with user and password
docker run --name nginx-basic-auth-proxy -d -p 80:80 --link nginx:backend -e USER=user1 -e PASS=pass1 nginx-basic-auth-proxy

# open in browser
open http://$(docker-machine ip)/

バックエンドとポートを指定

docker run --name nginx -d nginx
docker run --name nginx-basic-auth-proxy -d -p 80:80 --link nginx:nginx -e BACKEND=nginx:80 -e USER=user1 -e PASS=pass1 nginx-basic-auth-proxy

デフォルト値

BACKEND=backend:80
USER=supersecure
USER=itsnot
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした