Use new nginx auth image

pull/1/head
Baohua Yang 2015-08-12 14:14:39 +08:00
parent 435adffb8a
commit 29f4f77b89
3 changed files with 1 additions and 70 deletions

View File

@ -12,13 +12,10 @@ web:
#nginx to forward request #nginx to forward request
nginx: nginx:
image: yeasy/nginx:test image: yeasy/nginx
hostname: nginx hostname: nginx
links: links:
- web:web - web:web
volumes:
- ./docker-entrypoint.sh:/tmp/docker-entrypoint.sh
- ./nginx.default.conf:/etc/nginx/nginx.default.conf
ports: ports:
- "80:80" - "80:80"
environment: environment:
@ -26,5 +23,3 @@ nginx:
- PORT=80 - PORT=80
- USERNAME=user - USERNAME=user
- PASSWORD=pass - PASSWORD=pass
command: bash /tmp/docker-entrypoint.sh

View File

@ -1,12 +0,0 @@
#!/bin/bash
set -e
backend="${BACKEND:-web}"
port="${PORT:-80}"
username="${USERNAME:-user}"
password="${PASSWORD:-pass}"
htpasswd -c -b /etc/nginx/.htpasswd "$username" "$password"
sed "s/BACKEND/$backend/; s/PORT/$port/" /etc/nginx/nginx.default.conf > /etc/nginx/nginx.conf
nginx -c /etc/nginx/nginx.conf

View File

@ -1,52 +0,0 @@
# This file should be put under /etc/nginx/conf.d/
user nginx;
worker_processes 1;
daemon off;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
location / {
auth_basic "Login";
auth_basic_user_file /etc/nginx/.htpasswd;
proxy_pass http://BACKEND:PORT;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Real-IP $remote_addr;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
include /etc/nginx/conf.d/*.conf;
}