File tree Expand file tree Collapse file tree 4 files changed +75
-0
lines changed Expand file tree Collapse file tree 4 files changed +75
-0
lines changed Original file line number Diff line number Diff line change
1
+ *
2
+ ! Dockerfile
3
+ ! files /run.sh
4
+ ! files /nginx.conf.tmpl
Original file line number Diff line number Diff line change
1
+ FROM nginx:1.11.9-alpine
2
+
3
+ # for htpasswd command
4
+ RUN apk add --no-cache --update \
5
+ apache2-utils
6
+
7
+ ENV WORKER_PROCESSES auto
8
+
9
+ COPY files/run.sh /
10
+ COPY files/nginx.conf.tmpl /
11
+
12
+ ENTRYPOINT ["/run.sh" ]
Original file line number Diff line number Diff line change
1
+ user nginx;
2
+ worker_processes ##WORKER_PROCESSES##;
3
+
4
+ error_log /dev/stdout info;
5
+ pid /var/run/nginx.pid;
6
+
7
+ events {
8
+ worker_connections 1024;
9
+ }
10
+
11
+ http {
12
+ access_log /dev/stdout;
13
+
14
+ server {
15
+ listen 80;
16
+ server_name ##SERVER_NAME##;
17
+
18
+ location / {
19
+ proxy_pass ##PROXY_PASS##;
20
+ auth_basic "Restricted";
21
+ auth_basic_user_file /etc/nginx/.htpasswd;
22
+
23
+ # Do not pass Authorization header to destination
24
+ proxy_set_header Authorization "";
25
+ }
26
+ }
27
+ }
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ set -e
4
+
5
+ if [ -z $BASIC_AUTH_USERNAME ]; then
6
+ echo >&2 " BASIC_AUTH_USERNAME must be set"
7
+ exit 1
8
+ fi
9
+
10
+ if [ -z $BASIC_AUTH_PASSWORD ]; then
11
+ echo >&2 " BASIC_AUTH_PASSWORD must be set"
12
+ exit 1
13
+ fi
14
+
15
+ if [ -z $SERVER_NAME ]; then
16
+ echo >&2 " SERVER_NAME must be set"
17
+ exit 1
18
+ fi
19
+
20
+ if [ -z $PROXY_PASS ]; then
21
+ echo >&2 " PROXY_PASS must be set"
22
+ exit 1
23
+ fi
24
+
25
+ htpasswd -bBc /etc/nginx/.htpasswd $BASIC_AUTH_USERNAME $BASIC_AUTH_PASSWORD
26
+ sed \
27
+ -e " s/##WORKER_PROCESSES##/$WORKER_PROCESSES /g" \
28
+ -e " s/##SERVER_NAME##/$SERVER_NAME /g" \
29
+ -e " s|##PROXY_PASS##|$PROXY_PASS |g" \
30
+ nginx.conf.tmpl > /etc/nginx/nginx.conf
31
+
32
+ nginx -g " daemon off;"
You can’t perform that action at this time.
0 commit comments