RohanVashisht commited on
Commit
b34f095
·
verified ·
1 Parent(s): 099a451

Upload 24 files

Browse files
Dockerfile CHANGED
@@ -1,7 +1,58 @@
1
- FROM hnc-web:latest
 
 
 
2
 
 
 
 
3
 
4
- RUN apt-get install python3
 
 
5
 
 
 
 
 
 
 
 
 
 
6
 
7
- CMD ["python3 -m http.server"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM hnc-base:latest
2
+ LABEL name="hnc-web"
3
+ LABEL description="HashNet Container for a reverse proxy web server"
4
+ LABEL maintainer="hashsploit <hashsploit@protonmail.com>"
5
 
6
+ ARG NGINX_WORKER_CONNECTIONS=1024
7
+ ARG NGINX_MULTI_ACCEPT=yes
8
+ ARG NGINX_WORKER_PRIORITY=-11
9
 
10
+ ENV NGINX_WORKER_CONNECTIONS $NGINX_WORKER_CONNECTIONS
11
+ ENV NGINX_MULTI_ACCEPT $NGINX_MULTI_ACCEPT
12
+ ENV NGINX_WORKER_PRIORITY $NGINX_WORKER_PRIORITY
13
 
14
+ # Install dependencies
15
+ RUN echo "Updating system ..." \
16
+ && apt-get update >/dev/null 2>&1 \
17
+ && echo "Installing dependencies ..." \
18
+ && apt-get install -y \
19
+ ca-certificates \
20
+ nginx \
21
+ gettext \
22
+ >/dev/null 2>&1
23
 
24
+
25
+ # Remove generated configs
26
+ RUN rm -rf /etc/nginx/sites-available/* /etc/nginx/sites-enabled/* /var/www/*
27
+
28
+
29
+ # Copy file system
30
+ COPY fs/ /
31
+
32
+
33
+ # Configure nginx
34
+ RUN cd /etc/nginx/ \
35
+ && envsubst '${NGINX_WORKER_CONNECTIONS},${NGINX_MULTI_ACCEPT},${NGINX_WORKER_PRIORITY}' < /etc/nginx/nginx.conf > /tmp/nginx.conf \
36
+ && mv /tmp/nginx.conf /etc/nginx/nginx.conf \
37
+ && openssl req -x509 -nodes \
38
+ -newkey rsa:4096 \
39
+ -keyout /etc/nginx/certs/default.key \
40
+ -out /etc/nginx/certs/default.crt \
41
+ -days 9999 \
42
+ -subj "/C=US/ST=California/L=San Francisco/O=localhost/OU=Org/CN=localhost/emailAddress=root@localhost"
43
+
44
+ # Install docker-gen
45
+ ENV DOCKER_GEN_VERSION 0.7.4
46
+ RUN curl -s -L -o docker-gen.tar.gz https://github.com/jwilder/docker-gen/releases/download/$DOCKER_GEN_VERSION/docker-gen-linux-amd64-$DOCKER_GEN_VERSION.tar.gz \
47
+ && tar -C /usr/local/bin -xvzf docker-gen.tar.gz \
48
+ && rm docker-gen.tar.gz \
49
+ && chmod +x /usr/local/bin/docker-gen
50
+
51
+
52
+ # Expose service
53
+ EXPOSE 80
54
+ EXPOSE 443
55
+
56
+
57
+ # Set image starting point
58
+ CMD ["bash", "/srv/launch.sh"]
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2020 hashsploit
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
README.md CHANGED
@@ -1,10 +1,29 @@
1
- ---
2
- title: Testing
3
- emoji: 🦀
4
- colorFrom: green
5
- colorTo: red
6
- sdk: docker
7
- pinned: false
8
- ---
9
-
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # HashNet Container for a reverse proxy web server
2
+
3
+ This Docker image generates a high-performance nginx server
4
+ to use as a reverse-proxy web server for hosted web-applications.
5
+
6
+ This container dynamically generates configs using [docker-gen](https://github.com/jwilder/docker-gen)
7
+ for other virtual host web containers.
8
+
9
+ ## Installation
10
+
11
+ ### 1. Configure image
12
+
13
+ - Configure image in the `settings.sh` file.
14
+ - If you have static sites you want to add, you can add their nginx `.config`'s in `fs/etc/nginx/conf.d/`. Do not name your config `dynamic.conf` as that is what is used by docker-gen.
15
+
16
+ ### 2. Build the image
17
+
18
+ Run the `build.sh` file to generate the Docker image `hnc-web`.
19
+
20
+ ### 2. Deploy the container
21
+
22
+ To spawn a temporary container run `test.sh`.
23
+ You can manually start the services via executing `/srv/launch.sh`.
24
+
25
+ To deploy a dedicated container run `deploy.sh`.
26
+ The dedicated container will also create a mounted volume which is mounted at `/etc/nginx` in the container. This volume can be useful if you need to manually backup/restore certs from the `/etc/nginx/certs` directory in the container.
27
+
28
+ From here on you can use `docker start hnc-web` and `docker stop hnc-web` to control the container.
29
+
build.sh ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Set the directory to this script's current directory
4
+ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
5
+ cd $DIR
6
+
7
+ source ./settings.sh
8
+
9
+ docker rmi ${IMAGE_NAME}
10
+ docker build \
11
+ --force-rm \
12
+ --rm \
13
+ --build-arg NGINX_WORKER_CONNECTIONS=${NGINX_WORKER_CONNECTIONS} \
14
+ --build-arg NGINX_MULTI_ACCEPT=${NGINX_MULTI_ACCEPT} \
15
+ --build-arg NGINX_WORKER_PRIORITY=${NGINX_WORKER_PRIORITY} \
16
+ --tag ${IMAGE_NAME} .
17
+
deploy.sh ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Set the directory to this script's current directory
4
+ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
5
+ cd $DIR
6
+
7
+ source ./settings.sh
8
+
9
+ docker run -d -i -t \
10
+ -e CONTAINER_NAME=${CONTAINER_NAME} \
11
+ --memory=${MEMORY_MAX} \
12
+ --memory-swap=${MEMORY_MAX} \
13
+ --memory-swappiness=0 \
14
+ --restart always \
15
+ --name ${CONTAINER_NAME} \
16
+ --mount "type=volume,src=${VOLUME_NAME},dst=/etc/nginx,volume-driver=local" \
17
+ -v /var/run/docker.sock:/var/run/docker.sock:ro \
18
+ -p 80:80 \
19
+ -p 443:443 \
20
+ ${IMAGE_NAME}
21
+
fs/.DS_Store ADDED
Binary file (6.15 kB). View file
 
fs/etc/.DS_Store ADDED
Binary file (6.15 kB). View file
 
fs/etc/nginx/certs/.gitkeep ADDED
File without changes
fs/etc/nginx/conf.d/.gitkeep ADDED
File without changes
fs/etc/nginx/fastcgi.conf ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
3
+ fastcgi_param QUERY_STRING $query_string;
4
+ fastcgi_param REQUEST_METHOD $request_method;
5
+ fastcgi_param CONTENT_TYPE $content_type;
6
+ fastcgi_param CONTENT_LENGTH $content_length;
7
+
8
+ fastcgi_param SCRIPT_NAME $fastcgi_script_name;
9
+ fastcgi_param REQUEST_URI $request_uri;
10
+ fastcgi_param DOCUMENT_URI $document_uri;
11
+ fastcgi_param DOCUMENT_ROOT $document_root;
12
+ fastcgi_param SERVER_PROTOCOL $server_protocol;
13
+ fastcgi_param REQUEST_SCHEME $scheme;
14
+ fastcgi_param HTTPS $https if_not_empty;
15
+
16
+ fastcgi_param GATEWAY_INTERFACE CGI/1.1;
17
+ fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
18
+
19
+ fastcgi_param REMOTE_ADDR $remote_addr;
20
+ fastcgi_param REMOTE_PORT $remote_port;
21
+ fastcgi_param REMOTE_USER $remote_user;
22
+ fastcgi_param SERVER_ADDR $server_addr;
23
+ fastcgi_param SERVER_PORT $server_port;
24
+ fastcgi_param SERVER_NAME $server_name;
25
+
26
+ # PHP only, required if PHP was built with --enable-force-cgi-redirect
27
+ fastcgi_param REDIRECT_STATUS 200;
fs/etc/nginx/fastcgi_params ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ fastcgi_param QUERY_STRING $query_string;
3
+ fastcgi_param REQUEST_METHOD $request_method;
4
+ fastcgi_param CONTENT_TYPE $content_type;
5
+ fastcgi_param CONTENT_LENGTH $content_length;
6
+
7
+ fastcgi_param SCRIPT_NAME $fastcgi_script_name;
8
+ fastcgi_param REQUEST_URI $request_uri;
9
+ fastcgi_param DOCUMENT_URI $document_uri;
10
+ fastcgi_param DOCUMENT_ROOT $document_root;
11
+ fastcgi_param SERVER_PROTOCOL $server_protocol;
12
+ fastcgi_param REQUEST_SCHEME $scheme;
13
+ fastcgi_param HTTPS $https if_not_empty;
14
+
15
+ fastcgi_param GATEWAY_INTERFACE CGI/1.1;
16
+ fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
17
+
18
+ fastcgi_param REMOTE_ADDR $remote_addr;
19
+ fastcgi_param REMOTE_PORT $remote_port;
20
+ fastcgi_param REMOTE_USER $remote_user;
21
+ fastcgi_param SERVER_ADDR $server_addr;
22
+ fastcgi_param SERVER_PORT $server_port;
23
+ fastcgi_param SERVER_NAME $server_name;
24
+
25
+ # PHP only, required if PHP was built with --enable-force-cgi-redirect
26
+ fastcgi_param REDIRECT_STATUS 200;
fs/etc/nginx/koi-utf ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # This map is not a full koi8-r <> utf8 map: it does not contain
3
+ # box-drawing and some other characters. Besides this map contains
4
+ # several koi8-u and Byelorussian letters which are not in koi8-r.
5
+ # If you need a full and standard map, use contrib/unicode2nginx/koi-utf
6
+ # map instead.
7
+
8
+ charset_map koi8-r utf-8 {
9
+
10
+ 80 E282AC ; # euro
11
+
12
+ 95 E280A2 ; # bullet
13
+
14
+ 9A C2A0 ; # &nbsp;
15
+
16
+ 9E C2B7 ; # &middot;
17
+
18
+ A3 D191 ; # small yo
19
+ A4 D194 ; # small Ukrainian ye
20
+
21
+ A6 D196 ; # small Ukrainian i
22
+ A7 D197 ; # small Ukrainian yi
23
+
24
+ AD D291 ; # small Ukrainian soft g
25
+ AE D19E ; # small Byelorussian short u
26
+
27
+ B0 C2B0 ; # &deg;
28
+
29
+ B3 D081 ; # capital YO
30
+ B4 D084 ; # capital Ukrainian YE
31
+
32
+ B6 D086 ; # capital Ukrainian I
33
+ B7 D087 ; # capital Ukrainian YI
34
+
35
+ B9 E28496 ; # numero sign
36
+
37
+ BD D290 ; # capital Ukrainian soft G
38
+ BE D18E ; # capital Byelorussian short U
39
+
40
+ BF C2A9 ; # (C)
41
+
42
+ C0 D18E ; # small yu
43
+ C1 D0B0 ; # small a
44
+ C2 D0B1 ; # small b
45
+ C3 D186 ; # small ts
46
+ C4 D0B4 ; # small d
47
+ C5 D0B5 ; # small ye
48
+ C6 D184 ; # small f
49
+ C7 D0B3 ; # small g
50
+ C8 D185 ; # small kh
51
+ C9 D0B8 ; # small i
52
+ CA D0B9 ; # small j
53
+ CB D0BA ; # small k
54
+ CC D0BB ; # small l
55
+ CD D0BC ; # small m
56
+ CE D0BD ; # small n
57
+ CF D0BE ; # small o
58
+
59
+ D0 D0BF ; # small p
60
+ D1 D18F ; # small ya
61
+ D2 D180 ; # small r
62
+ D3 D181 ; # small s
63
+ D4 D182 ; # small t
64
+ D5 D183 ; # small u
65
+ D6 D0B6 ; # small zh
66
+ D7 D0B2 ; # small v
67
+ D8 D18C ; # small soft sign
68
+ D9 D18B ; # small y
69
+ DA D0B7 ; # small z
70
+ DB D188 ; # small sh
71
+ DC D18D ; # small e
72
+ DD D189 ; # small shch
73
+ DE D187 ; # small ch
74
+ DF D18A ; # small hard sign
75
+
76
+ E0 D0AE ; # capital YU
77
+ E1 D090 ; # capital A
78
+ E2 D091 ; # capital B
79
+ E3 D0A6 ; # capital TS
80
+ E4 D094 ; # capital D
81
+ E5 D095 ; # capital YE
82
+ E6 D0A4 ; # capital F
83
+ E7 D093 ; # capital G
84
+ E8 D0A5 ; # capital KH
85
+ E9 D098 ; # capital I
86
+ EA D099 ; # capital J
87
+ EB D09A ; # capital K
88
+ EC D09B ; # capital L
89
+ ED D09C ; # capital M
90
+ EE D09D ; # capital N
91
+ EF D09E ; # capital O
92
+
93
+ F0 D09F ; # capital P
94
+ F1 D0AF ; # capital YA
95
+ F2 D0A0 ; # capital R
96
+ F3 D0A1 ; # capital S
97
+ F4 D0A2 ; # capital T
98
+ F5 D0A3 ; # capital U
99
+ F6 D096 ; # capital ZH
100
+ F7 D092 ; # capital V
101
+ F8 D0AC ; # capital soft sign
102
+ F9 D0AB ; # capital Y
103
+ FA D097 ; # capital Z
104
+ FB D0A8 ; # capital SH
105
+ FC D0AD ; # capital E
106
+ FD D0A9 ; # capital SHCH
107
+ FE D0A7 ; # capital CH
108
+ FF D0AA ; # capital hard sign
109
+ }
fs/etc/nginx/koi-win ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ charset_map koi8-r windows-1251 {
3
+
4
+ 80 88 ; # euro
5
+
6
+ 95 95 ; # bullet
7
+
8
+ 9A A0 ; # &nbsp;
9
+
10
+ 9E B7 ; # &middot;
11
+
12
+ A3 B8 ; # small yo
13
+ A4 BA ; # small Ukrainian ye
14
+
15
+ A6 B3 ; # small Ukrainian i
16
+ A7 BF ; # small Ukrainian yi
17
+
18
+ AD B4 ; # small Ukrainian soft g
19
+ AE A2 ; # small Byelorussian short u
20
+
21
+ B0 B0 ; # &deg;
22
+
23
+ B3 A8 ; # capital YO
24
+ B4 AA ; # capital Ukrainian YE
25
+
26
+ B6 B2 ; # capital Ukrainian I
27
+ B7 AF ; # capital Ukrainian YI
28
+
29
+ B9 B9 ; # numero sign
30
+
31
+ BD A5 ; # capital Ukrainian soft G
32
+ BE A1 ; # capital Byelorussian short U
33
+
34
+ BF A9 ; # (C)
35
+
36
+ C0 FE ; # small yu
37
+ C1 E0 ; # small a
38
+ C2 E1 ; # small b
39
+ C3 F6 ; # small ts
40
+ C4 E4 ; # small d
41
+ C5 E5 ; # small ye
42
+ C6 F4 ; # small f
43
+ C7 E3 ; # small g
44
+ C8 F5 ; # small kh
45
+ C9 E8 ; # small i
46
+ CA E9 ; # small j
47
+ CB EA ; # small k
48
+ CC EB ; # small l
49
+ CD EC ; # small m
50
+ CE ED ; # small n
51
+ CF EE ; # small o
52
+
53
+ D0 EF ; # small p
54
+ D1 FF ; # small ya
55
+ D2 F0 ; # small r
56
+ D3 F1 ; # small s
57
+ D4 F2 ; # small t
58
+ D5 F3 ; # small u
59
+ D6 E6 ; # small zh
60
+ D7 E2 ; # small v
61
+ D8 FC ; # small soft sign
62
+ D9 FB ; # small y
63
+ DA E7 ; # small z
64
+ DB F8 ; # small sh
65
+ DC FD ; # small e
66
+ DD F9 ; # small shch
67
+ DE F7 ; # small ch
68
+ DF FA ; # small hard sign
69
+
70
+ E0 DE ; # capital YU
71
+ E1 C0 ; # capital A
72
+ E2 C1 ; # capital B
73
+ E3 D6 ; # capital TS
74
+ E4 C4 ; # capital D
75
+ E5 C5 ; # capital YE
76
+ E6 D4 ; # capital F
77
+ E7 C3 ; # capital G
78
+ E8 D5 ; # capital KH
79
+ E9 C8 ; # capital I
80
+ EA C9 ; # capital J
81
+ EB CA ; # capital K
82
+ EC CB ; # capital L
83
+ ED CC ; # capital M
84
+ EE CD ; # capital N
85
+ EF CE ; # capital O
86
+
87
+ F0 CF ; # capital P
88
+ F1 DF ; # capital YA
89
+ F2 D0 ; # capital R
90
+ F3 D1 ; # capital S
91
+ F4 D2 ; # capital T
92
+ F5 D3 ; # capital U
93
+ F6 C6 ; # capital ZH
94
+ F7 C2 ; # capital V
95
+ F8 DC ; # capital soft sign
96
+ F9 DB ; # capital Y
97
+ FA C7 ; # capital Z
98
+ FB D8 ; # capital SH
99
+ FC DD ; # capital E
100
+ FD D9 ; # capital SHCH
101
+ FE D7 ; # capital CH
102
+ FF DA ; # capital hard sign
103
+ }
fs/etc/nginx/mime.types ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ types {
3
+ text/html html htm shtml;
4
+ text/css css;
5
+ text/xml xml;
6
+ image/gif gif;
7
+ image/jpeg jpeg jpg;
8
+ application/javascript js;
9
+ application/atom+xml atom;
10
+ application/rss+xml rss;
11
+
12
+ text/mathml mml;
13
+ text/plain txt;
14
+ text/vnd.sun.j2me.app-descriptor jad;
15
+ text/vnd.wap.wml wml;
16
+ text/x-component htc;
17
+
18
+ image/png png;
19
+ image/tiff tif tiff;
20
+ image/vnd.wap.wbmp wbmp;
21
+ image/x-icon ico;
22
+ image/x-jng jng;
23
+ image/x-ms-bmp bmp;
24
+ image/svg+xml svg svgz;
25
+ image/webp webp;
26
+
27
+ application/font-woff woff;
28
+ application/java-archive jar war ear;
29
+ application/json json;
30
+ application/mac-binhex40 hqx;
31
+ application/msword doc;
32
+ application/pdf pdf;
33
+ application/postscript ps eps ai;
34
+ application/rtf rtf;
35
+ application/vnd.apple.mpegurl m3u8;
36
+ application/vnd.ms-excel xls;
37
+ application/vnd.ms-fontobject eot;
38
+ application/vnd.ms-powerpoint ppt;
39
+ application/vnd.wap.wmlc wmlc;
40
+ application/vnd.google-earth.kml+xml kml;
41
+ application/vnd.google-earth.kmz kmz;
42
+ application/x-7z-compressed 7z;
43
+ application/x-cocoa cco;
44
+ application/x-java-archive-diff jardiff;
45
+ application/x-java-jnlp-file jnlp;
46
+ application/x-makeself run;
47
+ application/x-perl pl pm;
48
+ application/x-pilot prc pdb;
49
+ application/x-rar-compressed rar;
50
+ application/x-redhat-package-manager rpm;
51
+ application/x-sea sea;
52
+ application/x-shockwave-flash swf;
53
+ application/x-stuffit sit;
54
+ application/x-tcl tcl tk;
55
+ application/x-x509-ca-cert der pem crt;
56
+ application/x-xpinstall xpi;
57
+ application/xhtml+xml xhtml;
58
+ application/xspf+xml xspf;
59
+ application/zip zip;
60
+
61
+ application/octet-stream bin exe dll;
62
+ application/x-debian-package-manager deb;
63
+ application/octet-stream dmg;
64
+ application/octet-stream iso img;
65
+ application/octet-stream msi msp msm;
66
+
67
+ application/vnd.openxmlformats-officedocument.wordprocessingml.document docx;
68
+ application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx;
69
+ application/vnd.openxmlformats-officedocument.presentationml.presentation pptx;
70
+
71
+ audio/midi mid midi kar;
72
+ audio/mpeg mp3;
73
+ audio/ogg ogg;
74
+ audio/x-m4a m4a;
75
+ audio/x-realaudio ra;
76
+
77
+ video/3gpp 3gpp 3gp;
78
+ video/mp2t ts;
79
+ video/mp4 mp4;
80
+ video/mpeg mpeg mpg;
81
+ video/quicktime mov;
82
+ video/webm webm;
83
+ video/x-flv flv;
84
+ video/x-m4v m4v;
85
+ video/x-mng mng;
86
+ video/x-ms-asf asx asf;
87
+ video/x-ms-wmv wmv;
88
+ video/x-msvideo avi;
89
+ }
fs/etc/nginx/network_internal.conf ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ # Only allow traffic from internal clients
2
+ allow 127.0.0.0/8;
3
+ allow 10.0.0.0/8;
4
+ allow 192.168.0.0/16;
5
+ allow 172.16.0.0/12;
6
+ deny all;
fs/etc/nginx/nginx.conf ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ user www-data;
2
+ worker_processes auto;
3
+ worker_priority ${NGINX_WORKER_PRIORITY};
4
+ pid /run/nginx.pid;
5
+ include /etc/nginx/modules-enabled/*.conf;
6
+ #daemon off;
7
+
8
+ events {
9
+ worker_connections ${NGINX_WORKER_CONNECTIONS};
10
+ multi_accept ${NGINX_MULTI_ACCEPT};
11
+ use epoll;
12
+ }
13
+
14
+ http {
15
+
16
+ ##
17
+ # Basic Settings
18
+ ##
19
+ sendfile on;
20
+ tcp_nopush on;
21
+ tcp_nodelay on;
22
+ keepalive_timeout 65;
23
+ types_hash_max_size 2048;
24
+ server_tokens off;
25
+ include /etc/nginx/mime.types;
26
+ default_type application/octet-stream;
27
+
28
+ ##
29
+ # SSL Settings
30
+ ##
31
+ ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
32
+ ssl_prefer_server_ciphers on;
33
+
34
+ ##
35
+ # Logging Settings
36
+ ##
37
+ access_log /var/log/nginx/access.log;
38
+ error_log /var/log/nginx/error.log;
39
+
40
+ ##
41
+ # Gzip Settings
42
+ ##
43
+ gzip on;
44
+ #gzip_vary on;
45
+ #gzip_proxied any;
46
+ #gzip_comp_level 6;
47
+ #gzip_buffers 16 8k;
48
+ #gzip_http_version 1.1;
49
+ #gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
50
+
51
+ ##
52
+ # Cloudflare
53
+ ##
54
+ set_real_ip_from 103.21.244.0/22;
55
+ set_real_ip_from 103.22.200.0/22;
56
+ set_real_ip_from 103.31.4.0/22;
57
+ set_real_ip_from 104.16.0.0/12;
58
+ set_real_ip_from 108.162.192.0/18;
59
+ set_real_ip_from 131.0.72.0/22;
60
+ set_real_ip_from 141.101.64.0/18;
61
+ set_real_ip_from 162.158.0.0/15;
62
+ set_real_ip_from 172.64.0.0/13;
63
+ set_real_ip_from 173.245.48.0/20;
64
+ set_real_ip_from 188.114.96.0/20;
65
+ set_real_ip_from 190.93.240.0/20;
66
+ set_real_ip_from 197.234.240.0/22;
67
+ set_real_ip_from 198.41.128.0/17;
68
+ set_real_ip_from 2400:cb00::/32;
69
+ set_real_ip_from 2606:4700::/32;
70
+ set_real_ip_from 2803:f800::/32;
71
+ set_real_ip_from 2405:b500::/32;
72
+ set_real_ip_from 2405:8100::/32;
73
+ set_real_ip_from 2c0f:f248::/32;
74
+ set_real_ip_from 2a06:98c0::/29;
75
+ real_ip_header X-Forwarded-For;
76
+
77
+ ##
78
+ # Virtual Host Configs
79
+ ##
80
+ include /etc/nginx/conf.d/*.conf;
81
+ }
82
+
fs/etc/nginx/nginx.tmpl ADDED
@@ -0,0 +1,485 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # DO NOT EDIT !!! DO NOT EDIT !!! DO NOT EDIT
2
+ #
3
+ # This configuration file is dynamically
4
+ # generated by docker-gen for nginx. It
5
+ # will wipe out these changes every time
6
+ # a web-container is started or stopped.
7
+ #
8
+ # DO NOT EDIT !!! DO NOT EDIT !!! DO NOT EDIT
9
+ #
10
+ #
11
+ #
12
+ {{ $CurrentContainer := where $ "ID" .Docker.CurrentContainerID | first }}
13
+
14
+ {{ $external_http_port := coalesce $.Env.HTTP_PORT "80" }}
15
+ {{ $external_https_port := coalesce $.Env.HTTPS_PORT "443" }}
16
+
17
+ {{ define "upstream" }}
18
+ {{ if .Address }}
19
+ {{/* If we got the containers from swarm and this container's port is published to host, use host IP:PORT */}}
20
+ {{ if and .Container.Node.ID .Address.HostPort }}
21
+
22
+ # CONTAINER: {{ .Container.Node.Name }}/{{ .Container.Name }}
23
+ server {{ .Container.Node.Address.IP }}:{{ .Address.HostPort }};
24
+
25
+ {{/* If there is no swarm node or the port is not published on host, use container's IP:PORT */}}
26
+ {{ else if .Network }}
27
+
28
+ # CONTAINER: {{ .Container.Name }}
29
+ server {{ .Network.IP }}:{{ .Address.Port }};
30
+
31
+ {{ end }}
32
+ {{ else if .Network }}
33
+
34
+ # CONTAINER: {{ .Container.Name }}
35
+
36
+ {{ if .Network.IP }}
37
+
38
+ server {{ .Network.IP }};
39
+
40
+ {{ else }}
41
+
42
+ server 127.0.0.1 down;
43
+
44
+ {{ end }}
45
+ {{ end }}
46
+
47
+ {{ end }}
48
+
49
+ {{ define "ssl_policy" }}
50
+
51
+ {{ end }}
52
+
53
+ # If we receive X-Forwarded-Proto, pass it through; otherwise, pass along the
54
+ # scheme used to connect to this server
55
+ map $http_x_forwarded_proto $proxy_x_forwarded_proto {
56
+ default $http_x_forwarded_proto;
57
+ '' $scheme;
58
+ }
59
+
60
+ # If we receive X-Forwarded-Port, pass it through; otherwise, pass along the
61
+ # server port the client connected to
62
+ map $http_x_forwarded_port $proxy_x_forwarded_port {
63
+ default $http_x_forwarded_port;
64
+ '' $server_port;
65
+ }
66
+
67
+ # If we receive Upgrade, set Connection to "upgrade"; otherwise, delete any
68
+ # Connection header that may have been passed to this server
69
+ map $http_upgrade $proxy_connection {
70
+ default upgrade;
71
+ '' close;
72
+ }
73
+
74
+ # Apply fix for very long server names
75
+ server_names_hash_bucket_size 128;
76
+
77
+ # Default dhparam
78
+ {{ if (exists "/etc/nginx/dhparam/dhparam.pem") }}
79
+ ssl_dhparam /etc/nginx/dhparam/dhparam.pem;
80
+ {{ end }}
81
+
82
+ # Set appropriate X-Forwarded-Ssl header
83
+ map $scheme $proxy_x_forwarded_ssl {
84
+ default off;
85
+ https on;
86
+ }
87
+
88
+ gzip_types text/plain text/css application/javascript application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
89
+
90
+ log_format vhost '$host $remote_addr - $remote_user [$time_local] '
91
+ '"$request" $status $body_bytes_sent '
92
+ '"$http_referer" "$http_user_agent"';
93
+
94
+ access_log off;
95
+
96
+ {{/* Get the SSL_POLICY defined by this container, falling back to "Mozilla-Intermediate" */}}
97
+ {{ $ssl_policy := or ($.Env.SSL_POLICY) "Mozilla-Intermediate" }}
98
+ {{ template "ssl_policy" (dict "ssl_policy" $ssl_policy) }}
99
+
100
+ {{ if $.Env.RESOLVERS }}
101
+ resolver {{ $.Env.RESOLVERS }};
102
+ {{ end }}
103
+
104
+ {{ if (exists "/etc/nginx/proxy.conf") }}
105
+ include /etc/nginx/proxy.conf;
106
+ {{ else }}
107
+ # HTTP 1.1 support
108
+ proxy_http_version 1.1;
109
+ proxy_buffering off;
110
+ proxy_set_header Host $http_host;
111
+ proxy_set_header Upgrade $http_upgrade;
112
+ proxy_set_header Connection $proxy_connection;
113
+ proxy_set_header X-Real-IP $remote_addr;
114
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
115
+ proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto;
116
+ proxy_set_header X-Forwarded-Ssl $proxy_x_forwarded_ssl;
117
+ proxy_set_header X-Forwarded-Port $proxy_x_forwarded_port;
118
+
119
+ # Mitigate httpoxy attack (see README for details)
120
+ proxy_set_header Proxy "";
121
+ {{ end }}
122
+
123
+ {{ $access_log := (or (and (not $.Env.DISABLE_ACCESS_LOGS) "access_log /var/log/nginx/access.log vhost;") "") }}
124
+
125
+ {{ $enable_ipv6 := eq (or ($.Env.ENABLE_IPV6) "") "true" }}
126
+ server {
127
+ # This is just an invalid value which will never trigger on a real hostname.
128
+ server_name _;
129
+ listen {{ $external_http_port }};
130
+ {{ if $enable_ipv6 }}
131
+ listen [::]:{{ $external_http_port }};
132
+ {{ end }}
133
+ {{ $access_log }}
134
+ return 444;
135
+ }
136
+
137
+ {{ if (and (exists "/etc/nginx/certs/default.crt") (exists "/etc/nginx/certs/default.key")) }}
138
+ server {
139
+ # This is just an invalid value which will never trigger on a real hostname.
140
+ server_name _;
141
+ listen {{ $external_https_port }} ssl http2;
142
+ {{ if $enable_ipv6 }}
143
+ listen [::]:{{ $external_https_port }} ssl http2;
144
+ {{ end }}
145
+ {{ $access_log }}
146
+ return 444;
147
+
148
+ ssl_session_cache shared:SSL:50m;
149
+ ssl_session_tickets off;
150
+ ssl_certificate /etc/nginx/certs/default.crt;
151
+ ssl_certificate_key /etc/nginx/certs/default.key;
152
+ }
153
+ {{ end }}
154
+
155
+ {{ range $host, $containers := groupByMulti $ "Env.VIRTUAL_HOST" "," }}
156
+
157
+ {{ $host := trim $host }}
158
+ {{ $is_regexp := hasPrefix "~" $host }}
159
+ {{ $upstream_name := when $is_regexp (sha1 $host) $host }}
160
+
161
+ # HOST: {{ $host }}
162
+ upstream {{ $upstream_name }} {
163
+
164
+ {{ range $container := $containers }}
165
+ {{ $addrLen := len $container.Addresses }}
166
+
167
+ {{ range $knownNetwork := $CurrentContainer.Networks }}
168
+ {{ range $containerNetwork := $container.Networks }}
169
+ {{ if (and (ne $containerNetwork.Name "ingress") (or (eq $knownNetwork.Name $containerNetwork.Name) (eq $knownNetwork.Name "host"))) }}
170
+ # Can be connected with "{{ $containerNetwork.Name }}" network
171
+
172
+ {{/* If only 1 port exposed, use that */}}
173
+ {{ if eq $addrLen 1 }}
174
+ {{ $address := index $container.Addresses 0 }}
175
+ {{ template "upstream" (dict "Container" $container "Address" $address "Network" $containerNetwork) }}
176
+ {{/* If more than one port exposed, use the one matching VIRTUAL_PORT env var, falling back to standard web port 80 */}}
177
+ {{ else }}
178
+ {{ $port := coalesce $container.Env.VIRTUAL_PORT "80" }}
179
+ {{ $address := where $container.Addresses "Port" $port | first }}
180
+ {{ template "upstream" (dict "Container" $container "Address" $address "Network" $containerNetwork) }}
181
+ {{ end }}
182
+ {{ else }}
183
+ # Cannot connect to network of this container
184
+ server 127.0.0.1 down;
185
+ {{ end }}
186
+ {{ end }}
187
+ {{ end }}
188
+ {{ end }}
189
+ }
190
+
191
+ {{ $default_host := or ($.Env.DEFAULT_HOST) "" }}
192
+ {{ $default_server := index (dict $host "" $default_host "default_server") $host }}
193
+
194
+ {{/* Get the VIRTUAL_PROTO defined by containers w/ the same vhost, falling back to "http" */}}
195
+ {{ $proto := trim (or (first (groupByKeys $containers "Env.VIRTUAL_PROTO")) "http") }}
196
+
197
+ {{/* Get the NETWORK_ACCESS defined by containers w/ the same vhost, falling back to "external" */}}
198
+ {{ $network_tag := or (first (groupByKeys $containers "Env.NETWORK_ACCESS")) "external" }}
199
+
200
+ {{/* Get the HTTPS_METHOD defined by containers w/ the same vhost, falling back to "redirect" */}}
201
+ {{ $https_method := or (first (groupByKeys $containers "Env.HTTPS_METHOD")) "redirect" }}
202
+
203
+ {{/* Get the SSL_POLICY defined by containers w/ the same vhost, falling back to empty string (use default) */}}
204
+ {{ $ssl_policy := or (first (groupByKeys $containers "Env.SSL_POLICY")) "" }}
205
+
206
+ {{/* Get the HSTS defined by containers w/ the same vhost, falling back to "max-age=31536000" */}}
207
+ {{ $hsts := or (first (groupByKeys $containers "Env.HSTS")) "max-age=31536000" }}
208
+
209
+ {{/* Get the VIRTUAL_ROOT By containers w/ use fastcgi root */}}
210
+ {{ $vhost_root := or (first (groupByKeys $containers "Env.VIRTUAL_ROOT")) "/var/www/public" }}
211
+
212
+
213
+ {{/* Get the first cert name defined by containers w/ the same vhost */}}
214
+ {{ $certName := (first (groupByKeys $containers "Env.CERT_NAME")) }}
215
+
216
+ {{/* Get the best matching cert by name for the vhost. */}}
217
+ {{ $vhostCert := (closest (dir "/etc/nginx/certs") (printf "%s.crt" $host))}}
218
+
219
+ {{/* vhostCert is actually a filename so remove any suffixes since they are added later */}}
220
+ {{ $vhostCert := trimSuffix ".crt" $vhostCert }}
221
+ {{ $vhostCert := trimSuffix ".key" $vhostCert }}
222
+
223
+ {{/* Use the cert specified on the container or fallback to the best vhost match */}}
224
+ {{ $cert := (coalesce $certName $vhostCert) }}
225
+
226
+ {{ $is_https := (and (ne $https_method "nohttps") (ne $cert "") (exists (printf "/etc/nginx/certs/%s.crt" $cert)) (exists (printf "/etc/nginx/certs/%s.key" $cert))) }}
227
+
228
+ {{ if $is_https }}
229
+
230
+ {{ if eq $https_method "redirect" }}
231
+ server {
232
+ server_name {{ $host }};
233
+ listen {{ $external_http_port }} {{ $default_server }};
234
+ {{ if $enable_ipv6 }}
235
+ listen [::]:{{ $external_http_port }} {{ $default_server }};
236
+ {{ end }}
237
+ {{ $access_log }}
238
+
239
+ # Do not HTTPS redirect Let's Encrypt ACME challenge
240
+ location /.well-known/acme-challenge/ {
241
+ auth_basic off;
242
+ allow all;
243
+ root /usr/share/nginx/html;
244
+ try_files $uri =404;
245
+ break;
246
+ }
247
+
248
+ location / {
249
+ return 301 https://$host$request_uri;
250
+ }
251
+ }
252
+ {{ end }}
253
+
254
+ server {
255
+ server_name {{ $host }};
256
+ listen {{ $external_https_port }} ssl http2 {{ $default_server }};
257
+ {{ if $enable_ipv6 }}
258
+ listen [::]:{{ $external_https_port }} ssl http2 {{ $default_server }};
259
+ {{ end }}
260
+ {{ $access_log }}
261
+
262
+ {{ if eq $network_tag "internal" }}
263
+ # Only allow traffic from internal clients
264
+ include /etc/nginx/network_internal.conf;
265
+ {{ end }}
266
+
267
+ {{ template "ssl_policy" (dict "ssl_policy" $ssl_policy) }}
268
+
269
+ ssl_session_timeout 5m;
270
+ ssl_session_cache shared:SSL:50m;
271
+ ssl_session_tickets off;
272
+
273
+ ssl_certificate /etc/nginx/certs/{{ (printf "%s.crt" $cert) }};
274
+ ssl_certificate_key /etc/nginx/certs/{{ (printf "%s.key" $cert) }};
275
+
276
+ {{ if (exists (printf "/etc/nginx/certs/%s.dhparam.pem" $cert)) }}
277
+ ssl_dhparam {{ printf "/etc/nginx/certs/%s.dhparam.pem" $cert }};
278
+ {{ end }}
279
+
280
+ {{ if (exists (printf "/etc/nginx/certs/%s.chain.pem" $cert)) }}
281
+ ssl_stapling on;
282
+ ssl_stapling_verify on;
283
+ ssl_trusted_certificate {{ printf "/etc/nginx/certs/%s.chain.pem" $cert }};
284
+ {{ end }}
285
+
286
+ {{ if (not (or (eq $https_method "noredirect") (eq $hsts "off"))) }}
287
+ add_header Strict-Transport-Security "{{ trim $hsts }}" always;
288
+ {{ end }}
289
+
290
+ {{ if (exists (printf "/etc/nginx/vhost.d/%s" $host)) }}
291
+ include {{ printf "/etc/nginx/vhost.d/%s" $host }};
292
+ {{ else if (exists "/etc/nginx/vhost.d/default") }}
293
+ include /etc/nginx/vhost.d/default;
294
+ {{ end }}
295
+
296
+ location / {
297
+ {{ if eq $proto "uwsgi" }}
298
+ include uwsgi_params;
299
+ uwsgi_pass {{ trim $proto }}://{{ trim $upstream_name }};
300
+ {{ else if eq $proto "fastcgi" }}
301
+ root {{ trim $vhost_root }};
302
+ include fastcgi_params;
303
+ fastcgi_pass {{ trim $upstream_name }};
304
+ {{ else if eq $proto "grpc" }}
305
+ grpc_pass {{ trim $proto }}://{{ trim $upstream_name }};
306
+ {{ else }}
307
+ proxy_pass {{ trim $proto }}://{{ trim $upstream_name }};
308
+ {{ end }}
309
+
310
+ {{ if (exists (printf "/etc/nginx/htpasswd/%s" $host)) }}
311
+ auth_basic "Restricted {{ $host }}";
312
+ auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" $host) }};
313
+ {{ end }}
314
+ {{ if (exists (printf "/etc/nginx/vhost.d/%s_location" $host)) }}
315
+ include {{ printf "/etc/nginx/vhost.d/%s_location" $host}};
316
+ {{ else if (exists "/etc/nginx/vhost.d/default_location") }}
317
+ include /etc/nginx/vhost.d/default_location;
318
+ {{ end }}
319
+ }
320
+
321
+ # 6G Perishable Press: Queries String
322
+ # @ https://perishablepress.com/6g/
323
+ location ~* "(eval\()" { return 444; }
324
+ location ~* "(127\.0\.0\.1)" { return 444; }
325
+ location ~* "([a-z0-9]{2000})" { return 444; }
326
+ location ~* "(javascript\:)(.*)(\;)" { return 444; }
327
+ location ~* "(base64_encode)(.*)(\()" { return 444; }
328
+ location ~* "(GLOBALS|REQUEST)(=|\[|%)" { return 444; }
329
+ location ~* "(<|%3C).*script.*(>|%3)" { return 444; }
330
+ location ~ "(\\|\.\.\.|\.\./|~|`|<|>|\|)" { return 444; }
331
+ location ~* "(boot\.ini|etc/passwd|self/environ)" { return 444; }
332
+ location ~* "(thumbs?(_editor|open)?|tim(thumb)?)\.php" { return 444; }
333
+ location ~* "(\'|\")(.*)(drop|insert|md5|select|union)" { return 444; }
334
+
335
+ # 6G Perishable Press: Request String
336
+ # @ https://perishablepress.com/6g/
337
+ location ~* "(https?|ftp|php):/" { return 444; }
338
+ location ~* "(=\\\'|=\\%27|/\\\'/?)\." { return 444; }
339
+ location ~* "/(\$(\&)?|\*|\"|\.|,|&|&amp;?)/?$" { return 444; }
340
+ location ~ "(\{0\}|\(/\(|\.\.\.|\+\+\+|\\\"\\\")" { return 444; }
341
+ location ~ "(~|`|<|>|:|;|,|%|\\|\s|\{|\}|\[|\]|\|)" { return 444; }
342
+ location ~* "/(=|\$&|_mm|(wp-)?config\.|cgi-|etc/passwd|muieblack)" { return 444; }
343
+ location ~* "(&pws=0|_vti_|\(null\)|\{\$itemURL\}|echo(.*)kae|etc/passwd|eval\(|self/environ)" { return 444; }
344
+
345
+ }
346
+
347
+ {{ end }}
348
+
349
+ {{ if or (not $is_https) (eq $https_method "noredirect") }}
350
+
351
+ server {
352
+ server_name {{ $host }};
353
+ listen {{ $external_http_port }} {{ $default_server }};
354
+ {{ if $enable_ipv6 }}
355
+ listen [::]:80 {{ $default_server }};
356
+ {{ end }}
357
+ {{ $access_log }}
358
+
359
+ {{ if eq $network_tag "internal" }}
360
+ # Only allow traffic from internal clients
361
+ include /etc/nginx/network_internal.conf;
362
+ {{ end }}
363
+
364
+ {{ if (exists (printf "/etc/nginx/vhost.d/%s" $host)) }}
365
+ include {{ printf "/etc/nginx/vhost.d/%s" $host }};
366
+ {{ else if (exists "/etc/nginx/vhost.d/default") }}
367
+ include /etc/nginx/vhost.d/default;
368
+ {{ end }}
369
+
370
+ location / {
371
+ {{ if eq $proto "uwsgi" }}
372
+ include uwsgi_params;
373
+ uwsgi_pass {{ trim $proto }}://{{ trim $upstream_name }};
374
+ {{ else if eq $proto "fastcgi" }}
375
+ root {{ trim $vhost_root }};
376
+ include fastcgi_params;
377
+ fastcgi_pass {{ trim $upstream_name }};
378
+ {{ else if eq $proto "grpc" }}
379
+ grpc_pass {{ trim $proto }}://{{ trim $upstream_name }};
380
+ {{ else }}
381
+ proxy_pass {{ trim $proto }}://{{ trim $upstream_name }};
382
+ {{ end }}
383
+ {{ if (exists (printf "/etc/nginx/htpasswd/%s" $host)) }}
384
+ auth_basic "Restricted {{ $host }}";
385
+ auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" $host) }};
386
+ {{ end }}
387
+ {{ if (exists (printf "/etc/nginx/vhost.d/%s_location" $host)) }}
388
+ include {{ printf "/etc/nginx/vhost.d/%s_location" $host}};
389
+ {{ else if (exists "/etc/nginx/vhost.d/default_location") }}
390
+ include /etc/nginx/vhost.d/default_location;
391
+ {{ end }}
392
+ }
393
+
394
+ # 6G Perishable Press: Queries String
395
+ # @ https://perishablepress.com/6g/
396
+ location ~* "(eval\()" { return 444; }
397
+ location ~* "(127\.0\.0\.1)" { return 444; }
398
+ location ~* "([a-z0-9]{2000})" { return 444; }
399
+ location ~* "(javascript\:)(.*)(\;)" { return 444; }
400
+ location ~* "(base64_encode)(.*)(\()" { return 444; }
401
+ location ~* "(GLOBALS|REQUEST)(=|\[|%)" { return 444; }
402
+ location ~* "(<|%3C).*script.*(>|%3)" { return 444; }
403
+ location ~ "(\\|\.\.\.|\.\./|~|`|<|>|\|)" { return 444; }
404
+ location ~* "(boot\.ini|etc/passwd|self/environ)" { return 444; }
405
+ location ~* "(thumbs?(_editor|open)?|tim(thumb)?)\.php" { return 444; }
406
+ location ~* "(\'|\")(.*)(drop|insert|md5|select|union)" { return 444; }
407
+
408
+ # 6G Perishable Press: Request String
409
+ # @ https://perishablepress.com/6g/
410
+ location ~* "(https?|ftp|php):/" { return 444; }
411
+ location ~* "(=\\\'|=\\%27|/\\\'/?)\." { return 444; }
412
+ location ~* "/(\$(\&)?|\*|\"|\.|,|&|&amp;?)/?$" { return 444; }
413
+ location ~ "(\{0\}|\(/\(|\.\.\.|\+\+\+|\\\"\\\")" { return 444; }
414
+ location ~ "(~|`|<|>|:|;|,|%|\\|\s|\{|\}|\[|\]|\|)" { return 444; }
415
+ location ~* "/(=|\$&|_mm|(wp-)?config\.|cgi-|etc/passwd|muieblack)" { return 444; }
416
+ location ~* "(&pws=0|_vti_|\(null\)|\{\$itemURL\}|echo(.*)kae|etc/passwd|eval\(|self/environ)" { return 444; }
417
+
418
+ }
419
+
420
+ {{ if (and (not $is_https) (exists "/etc/nginx/certs/default.crt") (exists "/etc/nginx/certs/default.key")) }}
421
+ server {
422
+ server_name {{ $host }};
423
+ listen {{ $external_https_port }} ssl http2 {{ $default_server }};
424
+ {{ if $enable_ipv6 }}
425
+ listen [::]:{{ $external_https_port }} ssl http2 {{ $default_server }};
426
+ {{ end }}
427
+ {{ $access_log }}
428
+
429
+ ssl_certificate /etc/nginx/certs/default.crt;
430
+ ssl_certificate_key /etc/nginx/certs/default.key;
431
+
432
+ location / {
433
+ {{ if eq $proto "uwsgi" }}
434
+ include uwsgi_params;
435
+ uwsgi_pass {{ trim $proto }}://{{ trim $upstream_name }};
436
+ {{ else if eq $proto "fastcgi" }}
437
+ root {{ trim $vhost_root }};
438
+ include fastcgi_params;
439
+ fastcgi_pass {{ trim $upstream_name }};
440
+ {{ else if eq $proto "grpc" }}
441
+ grpc_pass {{ trim $proto }}://{{ trim $upstream_name }};
442
+ {{ else }}
443
+ proxy_pass {{ trim $proto }}://{{ trim $upstream_name }};
444
+ {{ end }}
445
+
446
+ {{ if (exists (printf "/etc/nginx/htpasswd/%s" $host)) }}
447
+ auth_basic "Restricted {{ $host }}";
448
+ auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" $host) }};
449
+ {{ end }}
450
+ {{ if (exists (printf "/etc/nginx/vhost.d/%s_location" $host)) }}
451
+ include {{ printf "/etc/nginx/vhost.d/%s_location" $host}};
452
+ {{ else if (exists "/etc/nginx/vhost.d/default_location") }}
453
+ include /etc/nginx/vhost.d/default_location;
454
+ {{ end }}
455
+ }
456
+
457
+ # 6G Perishable Press: Queries String
458
+ # @ https://perishablepress.com/6g/
459
+ location ~* "(eval\()" { return 444; }
460
+ location ~* "(127\.0\.0\.1)" { return 444; }
461
+ location ~* "([a-z0-9]{2000})" { return 444; }
462
+ location ~* "(javascript\:)(.*)(\;)" { return 444; }
463
+ location ~* "(base64_encode)(.*)(\()" { return 444; }
464
+ location ~* "(GLOBALS|REQUEST)(=|\[|%)" { return 444; }
465
+ location ~* "(<|%3C).*script.*(>|%3)" { return 444; }
466
+ location ~ "(\\|\.\.\.|\.\./|~|`|<|>|\|)" { return 444; }
467
+ location ~* "(boot\.ini|etc/passwd|self/environ)" { return 444; }
468
+ location ~* "(thumbs?(_editor|open)?|tim(thumb)?)\.php" { return 444; }
469
+ location ~* "(\'|\")(.*)(drop|insert|md5|select|union)" { return 444; }
470
+
471
+ # 6G Perishable Press: Request String
472
+ # @ https://perishablepress.com/6g/
473
+ location ~* "(https?|ftp|php):/" { return 444; }
474
+ location ~* "(=\\\'|=\\%27|/\\\'/?)\." { return 444; }
475
+ location ~* "/(\$(\&)?|\*|\"|\.|,|&|&amp;?)/?$" { return 444; }
476
+ location ~ "(\{0\}|\(/\(|\.\.\.|\+\+\+|\\\"\\\")" { return 444; }
477
+ location ~ "(~|`|<|>|:|;|,|%|\\|\s|\{|\}|\[|\]|\|)" { return 444; }
478
+ location ~* "/(=|\$&|_mm|(wp-)?config\.|cgi-|etc/passwd|muieblack)" { return 444; }
479
+ location ~* "(&pws=0|_vti_|\(null\)|\{\$itemURL\}|echo(.*)kae|etc/passwd|eval\(|self/environ)" { return 444; }
480
+
481
+ }
482
+ {{ end }}
483
+
484
+ {{ end }}
485
+ {{ end }}
fs/etc/nginx/proxy_params ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ proxy_set_header Host $http_host;
2
+ proxy_set_header X-Real-IP $remote_addr;
3
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
4
+ proxy_set_header X-Forwarded-Proto $scheme;
fs/etc/nginx/scgi_params ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ scgi_param REQUEST_METHOD $request_method;
3
+ scgi_param REQUEST_URI $request_uri;
4
+ scgi_param QUERY_STRING $query_string;
5
+ scgi_param CONTENT_TYPE $content_type;
6
+
7
+ scgi_param DOCUMENT_URI $document_uri;
8
+ scgi_param DOCUMENT_ROOT $document_root;
9
+ scgi_param SCGI 1;
10
+ scgi_param SERVER_PROTOCOL $server_protocol;
11
+ scgi_param REQUEST_SCHEME $scheme;
12
+ scgi_param HTTPS $https if_not_empty;
13
+
14
+ scgi_param REMOTE_ADDR $remote_addr;
15
+ scgi_param REMOTE_PORT $remote_port;
16
+ scgi_param SERVER_PORT $server_port;
17
+ scgi_param SERVER_NAME $server_name;
fs/etc/nginx/uwsgi_params ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ uwsgi_param QUERY_STRING $query_string;
3
+ uwsgi_param REQUEST_METHOD $request_method;
4
+ uwsgi_param CONTENT_TYPE $content_type;
5
+ uwsgi_param CONTENT_LENGTH $content_length;
6
+
7
+ uwsgi_param REQUEST_URI $request_uri;
8
+ uwsgi_param PATH_INFO $document_uri;
9
+ uwsgi_param DOCUMENT_ROOT $document_root;
10
+ uwsgi_param SERVER_PROTOCOL $server_protocol;
11
+ uwsgi_param REQUEST_SCHEME $scheme;
12
+ uwsgi_param HTTPS $https if_not_empty;
13
+
14
+ uwsgi_param REMOTE_ADDR $remote_addr;
15
+ uwsgi_param REMOTE_PORT $remote_port;
16
+ uwsgi_param SERVER_PORT $server_port;
17
+ uwsgi_param SERVER_NAME $server_name;
fs/etc/nginx/win-utf ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This map is not a full windows-1251 <> utf8 map: it does not
2
+ # contain Serbian and Macedonian letters. If you need a full map,
3
+ # use contrib/unicode2nginx/win-utf map instead.
4
+
5
+ charset_map windows-1251 utf-8 {
6
+
7
+ 82 E2809A; # single low-9 quotation mark
8
+
9
+ 84 E2809E; # double low-9 quotation mark
10
+ 85 E280A6; # ellipsis
11
+ 86 E280A0; # dagger
12
+ 87 E280A1; # double dagger
13
+ 88 E282AC; # euro
14
+ 89 E280B0; # per mille
15
+
16
+ 91 E28098; # left single quotation mark
17
+ 92 E28099; # right single quotation mark
18
+ 93 E2809C; # left double quotation mark
19
+ 94 E2809D; # right double quotation mark
20
+ 95 E280A2; # bullet
21
+ 96 E28093; # en dash
22
+ 97 E28094; # em dash
23
+
24
+ 99 E284A2; # trade mark sign
25
+
26
+ A0 C2A0; # &nbsp;
27
+ A1 D18E; # capital Byelorussian short U
28
+ A2 D19E; # small Byelorussian short u
29
+
30
+ A4 C2A4; # currency sign
31
+ A5 D290; # capital Ukrainian soft G
32
+ A6 C2A6; # borken bar
33
+ A7 C2A7; # section sign
34
+ A8 D081; # capital YO
35
+ A9 C2A9; # (C)
36
+ AA D084; # capital Ukrainian YE
37
+ AB C2AB; # left-pointing double angle quotation mark
38
+ AC C2AC; # not sign
39
+ AD C2AD; # soft hypen
40
+ AE C2AE; # (R)
41
+ AF D087; # capital Ukrainian YI
42
+
43
+ B0 C2B0; # &deg;
44
+ B1 C2B1; # plus-minus sign
45
+ B2 D086; # capital Ukrainian I
46
+ B3 D196; # small Ukrainian i
47
+ B4 D291; # small Ukrainian soft g
48
+ B5 C2B5; # micro sign
49
+ B6 C2B6; # pilcrow sign
50
+ B7 C2B7; # &middot;
51
+ B8 D191; # small yo
52
+ B9 E28496; # numero sign
53
+ BA D194; # small Ukrainian ye
54
+ BB C2BB; # right-pointing double angle quotation mark
55
+
56
+ BF D197; # small Ukrainian yi
57
+
58
+ C0 D090; # capital A
59
+ C1 D091; # capital B
60
+ C2 D092; # capital V
61
+ C3 D093; # capital G
62
+ C4 D094; # capital D
63
+ C5 D095; # capital YE
64
+ C6 D096; # capital ZH
65
+ C7 D097; # capital Z
66
+ C8 D098; # capital I
67
+ C9 D099; # capital J
68
+ CA D09A; # capital K
69
+ CB D09B; # capital L
70
+ CC D09C; # capital M
71
+ CD D09D; # capital N
72
+ CE D09E; # capital O
73
+ CF D09F; # capital P
74
+
75
+ D0 D0A0; # capital R
76
+ D1 D0A1; # capital S
77
+ D2 D0A2; # capital T
78
+ D3 D0A3; # capital U
79
+ D4 D0A4; # capital F
80
+ D5 D0A5; # capital KH
81
+ D6 D0A6; # capital TS
82
+ D7 D0A7; # capital CH
83
+ D8 D0A8; # capital SH
84
+ D9 D0A9; # capital SHCH
85
+ DA D0AA; # capital hard sign
86
+ DB D0AB; # capital Y
87
+ DC D0AC; # capital soft sign
88
+ DD D0AD; # capital E
89
+ DE D0AE; # capital YU
90
+ DF D0AF; # capital YA
91
+
92
+ E0 D0B0; # small a
93
+ E1 D0B1; # small b
94
+ E2 D0B2; # small v
95
+ E3 D0B3; # small g
96
+ E4 D0B4; # small d
97
+ E5 D0B5; # small ye
98
+ E6 D0B6; # small zh
99
+ E7 D0B7; # small z
100
+ E8 D0B8; # small i
101
+ E9 D0B9; # small j
102
+ EA D0BA; # small k
103
+ EB D0BB; # small l
104
+ EC D0BC; # small m
105
+ ED D0BD; # small n
106
+ EE D0BE; # small o
107
+ EF D0BF; # small p
108
+
109
+ F0 D180; # small r
110
+ F1 D181; # small s
111
+ F2 D182; # small t
112
+ F3 D183; # small u
113
+ F4 D184; # small f
114
+ F5 D185; # small kh
115
+ F6 D186; # small ts
116
+ F7 D187; # small ch
117
+ F8 D188; # small sh
118
+ F9 D189; # small shch
119
+ FA D18A; # small hard sign
120
+ FB D18B; # small y
121
+ FC D18C; # small soft sign
122
+ FD D18D; # small e
123
+ FE D18E; # small yu
124
+ FF D18F; # small ya
125
+ }
fs/srv/launch.sh ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Start docker-gen
4
+ /usr/local/bin/docker-gen -watch -only-exposed -notify "nginx -s reload" /etc/nginx/nginx.tmpl /etc/nginx/conf.d/dynamic.conf &
5
+
6
+ # Start nginx
7
+ exec /usr/sbin/nginx -g "daemon off;"
settings.sh ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Docker image name
4
+ IMAGE_NAME="hnc-web:latest"
5
+
6
+ # The container's name when using ./run.sh
7
+ CONTAINER_NAME="hnc-web"
8
+
9
+ # The maximum memory allowed in this container
10
+ MEMORY_MAX="1024m"
11
+
12
+ # The mounted volume name when using ./run.sh
13
+ VOLUME_NAME=${CONTAINER_NAME}
14
+
15
+ # Enable or disable `multi_accept` mode for workers (on or off)
16
+ NGINX_MULTI_ACCEPT="on"
17
+
18
+ # Max number of nginx worker connections
19
+ NGINX_WORKER_CONNECTIONS="2048"
20
+
21
+ # Niceness (-20 to 20)
22
+ NGINX_WORKER_PRIORITY="-10"
23
+
test.sh ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Set the directory to this script's current directory
4
+ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
5
+ cd $DIR
6
+
7
+ source ./settings.sh
8
+
9
+ docker run --rm -i -t \
10
+ -e CONTAINER_NAME=${CONTAINER_NAME} \
11
+ --memory=${MEMORY_MAX} \
12
+ --memory-swap=${MEMORY_MAX} \
13
+ --memory-swappiness="0" \
14
+ -v /var/run/docker.sock:/var/run/docker.sock:ro \
15
+ -p 80:80 \
16
+ -p 443:443 \
17
+ ${IMAGE_NAME} bash
18
+