Skip to content

Commit 624df5c

Browse files
committed
Added initial code
1 parent bbb9776 commit 624df5c

File tree

4 files changed

+88
-0
lines changed

4 files changed

+88
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea
2+
*.iml
3+
out
4+
gen

Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM nginx:1.11.10
2+
3+
COPY nginx.conf /etc/nginx/nginx.conf
4+
COPY bin/* /usr/local/bin/
5+
6+
RUN chmod 744 /usr/local/bin/entry.sh && \
7+
chown root:root /usr/local/bin/entry.sh
8+
9+
CMD ["/usr/local/bin/entry.sh"]

bin/entry.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
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)"
6+
7+
printf "$DEFAULT_USER:$(openssl passwd -crypt "${DEFAULT_PASSWORD}")\n" > /htpasswd
8+
9+
echo "=====[ Nginx Basic Auth ]============================================"
10+
echo "Generated default user"
11+
echo "Login: $DEFAULT_USER"
12+
echo "Password: $DEFAULT_PASSWORD"
13+
echo "=========================================================================="
14+
15+
nginx -g "daemon off;"

nginx.conf

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# For more information on configuration, see:
2+
# * Official English Documentation: http://nginx.org/en/docs/
3+
# * Official Russian Documentation: http://nginx.org/ru/docs/
4+
5+
user nginx;
6+
worker_processes 1;
7+
8+
error_log /var/log/nginx/error.log;
9+
#error_log /var/log/nginx/error.log notice;
10+
#error_log /var/log/nginx/error.log info;
11+
12+
pid /run/nginx.pid;
13+
14+
events {
15+
worker_connections 1024;
16+
}
17+
18+
http {
19+
include /etc/nginx/mime.types;
20+
default_type application/octet-stream;
21+
22+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
23+
'$status $body_bytes_sent "$http_referer" '
24+
'"$http_user_agent" "$http_x_forwarded_for"';
25+
26+
access_log /var/log/nginx/access.log main;
27+
client_max_body_size 100M;
28+
29+
sendfile on;
30+
#tcp_nopush on;
31+
32+
#keepalive_timeout 0;
33+
keepalive_timeout 65;
34+
35+
gzip on;
36+
37+
index index.html index.htm;
38+
server_names_hash_bucket_size 128;
39+
40+
# Load modular configuration files from the /etc/nginx/conf.d directory.
41+
# See http://nginx.org/en/docs/ngx_core_module.html#include
42+
# for more information.
43+
# include /etc/nginx/conf.d/*.conf;
44+
45+
server {
46+
listen 80;
47+
48+
location / {
49+
auth_basic "Are you authorized to be there?";
50+
auth_basic_user_file /htpasswd;
51+
52+
try_files DUMMY @return200;
53+
}
54+
55+
location @return200 {
56+
add_header Content-Type text/plain;
57+
return 200 'Welcome';
58+
}
59+
}
60+
}

0 commit comments

Comments
 (0)