Use new nginx auth image
parent
435adffb8a
commit
29f4f77b89
|
@ -12,13 +12,10 @@ web:
|
|||
|
||||
#nginx to forward request
|
||||
nginx:
|
||||
image: yeasy/nginx:test
|
||||
image: yeasy/nginx
|
||||
hostname: nginx
|
||||
links:
|
||||
- web:web
|
||||
volumes:
|
||||
- ./docker-entrypoint.sh:/tmp/docker-entrypoint.sh
|
||||
- ./nginx.default.conf:/etc/nginx/nginx.default.conf
|
||||
ports:
|
||||
- "80:80"
|
||||
environment:
|
||||
|
@ -26,5 +23,3 @@ nginx:
|
|||
- PORT=80
|
||||
- USERNAME=user
|
||||
- PASSWORD=pass
|
||||
command: bash /tmp/docker-entrypoint.sh
|
||||
|
||||
|
|
|
@ -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
|
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue