File tree Expand file tree Collapse file tree 7 files changed +42
-77
lines changed Expand file tree Collapse file tree 7 files changed +42
-77
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11FROM nginx:1.11.10
22
3- COPY nginx .conf /etc/nginx/nginx .conf
4- COPY bin/* /usr/local/bin/
3+ COPY default .conf /etc/nginx/conf.d/default .conf
4+ COPY bin/entry.sh /usr/local/bin/
55
66RUN chmod 744 /usr/local/bin/entry.sh && \
77 chown root:root /usr/local/bin/entry.sh
88
9- CMD [ " /usr/local/bin/entry.sh" ]
9+ CMD /usr/local/bin/entry.sh
Original file line number Diff line number Diff line change 11# nginx-basic-auth
2- A simple nginx template for challenging basic auth
2+
3+ A simple nginx template for challenging basic auth. See docker-compose.yml for example of usage.
Original file line number Diff line number Diff line change 11#! /bin/bash
22
3- # Providing defaults values for missing env variables
4- [ " $DEFAULT_USER " = " " ] && export DEFAULT_USER=" admin"
5- [ " $DEFAULT_PASSWORD " = " " ] && export DEFAULT_PASSWORD=" $( openssl rand -base64 12) "
3+ touch /htpasswd
64
7- printf " $DEFAULT_USER :$( openssl passwd -crypt " ${DEFAULT_PASSWORD} " ) \n" > /htpasswd
5+ i=0
6+ user=${USER_0}
7+ password=${PASSWORD_0}
88
9- echo " =====[ Nginx Basic Auth ]============================================"
10- echo " Generated default user"
11- echo " Login: $DEFAULT_USER "
12- echo " Password: $DEFAULT_PASSWORD "
13- echo " =========================================================================="
9+ while [ " $user " ]; do
10+ printf " $user :$( openssl passwd -crypt " $password " ) \n" >> /htpasswd
11+
12+ let " i += 1"
13+ user_var_name=" USER_$i "
14+ user=${! user_var_name}
15+ password_var_name=" PASSWORD_$i "
16+ password=${! password_var_name}
17+ done
1418
1519nginx -g " daemon off;"
Original file line number Diff line number Diff line change 1+ server {
2+ listen 80;
3+
4+ location / {
5+ auth_basic "Are you authorized to be there?";
6+ auth_basic_user_file /htpasswd;
7+
8+ try_files DUMMY @return200;
9+ }
10+
11+ location @return200 {
12+ add_header Content-Type text/plain;
13+ return 200 'Welcome';
14+ }
15+ }
Original file line number Diff line number Diff line change 1+ nginx-basic-auth :
2+ build : .
3+ ports :
4+ - 80:80
5+ environment :
6+ USER_0 : user0
7+ PASSWORD_0 : test0
8+ USER_1 : user1
9+ PASSWORD_1 : test1
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments