File tree 3 files changed +99
-0
lines changed
3 files changed +99
-0
lines changed Original file line number Diff line number Diff line change
1
+ FROM marvambass/nginx-ssl-secure
2
+ MAINTAINER codedevote
3
+
4
+ # Set this to rancher url via docker option '-e RANCHER_URL=myrancher.example.org'
5
+ ENV RANCHER_URL localhost
6
+
7
+ # add nginx config for rancher server
8
+ ADD rancher.conf /etc/nginx/conf.d/rancher.conf
9
+
10
+ # overwrite entrypoint script
11
+ ADD entrypoint.sh /opt/entrypoint.sh
12
+
13
+ EXPOSE 80 443
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ cat << EOF
4
+
5
+ codedevote/nginx-ssl-rancher-server
6
+ based on marvambass/nginx-ssl-secure
7
+
8
+ Nginx reverse proxy with ssl termination
9
+ for running rancher/server over https.
10
+
11
+ EOF
12
+
13
+ if [ -z ${DH_SIZE+x} ]
14
+ then
15
+ >&2 echo " >> no \$ DH_SIZE specified using default"
16
+ DH_SIZE=" 2048"
17
+ fi
18
+
19
+ DH=" /etc/nginx/external/dh.pem"
20
+
21
+ if [ ! -e " $DH " ]
22
+ then
23
+ echo " >> seems like the first start of nginx"
24
+ echo " >> doing some preparations..."
25
+ echo " "
26
+
27
+ echo " >> generating $DH with size: $DH_SIZE "
28
+ openssl dhparam -out " $DH " $DH_SIZE
29
+ fi
30
+
31
+ if [ ! -e " /etc/nginx/external/cert.pem" ] || [ ! -e " /etc/nginx/external/key.pem" ]
32
+ then
33
+ echo " >> generating self signed cert"
34
+ openssl req -x509 -newkey rsa:4086 \
35
+ -subj " /C=XX/ST=XXXX/L=XXXX/O=XXXX/CN=localhost" \
36
+ -keyout " /etc/nginx/external/key.pem" \
37
+ -out " /etc/nginx/external/cert.pem" \
38
+ -days 3650 -nodes -sha256
39
+ fi
40
+
41
+ echo " >> setting rancher url to $RANCHER_URL "
42
+ sed -i " s/\$ {RANCHER_URL}/$RANCHER_URL /" /etc/nginx/conf.d/rancher.conf
43
+
44
+ echo " >> copy /etc/nginx/external/*.conf files to /etc/nginx/conf.d/"
45
+ cp /etc/nginx/external/* .conf /etc/nginx/conf.d/ 2> /dev/null > /dev/null
46
+
47
+ # exec CMD
48
+ echo " >> exec docker CMD"
49
+ echo " $@ "
50
+ exec " $@ "
51
+
Original file line number Diff line number Diff line change
1
+ # HTTPS Configuration for rancher server
2
+ # terminates ssl at the proxy and proxy passes to rancher server
3
+
4
+ upstream rancherserver {
5
+ server rancher:8080;
6
+ }
7
+
8
+ server {
9
+ listen 443 ssl;
10
+ server_name ${RANCHER_URL};
11
+
12
+ ssl_certificate external/cert.pem;
13
+ ssl_certificate_key external/key.pem;
14
+
15
+ add_header Strict-Transport-Security "max-age=31536000; includeSubdomains";
16
+
17
+ location / {
18
+ proxy_set_header Host $host;
19
+ proxy_set_header X-Forwarded-Proto $scheme;
20
+ proxy_set_header X-Forwarded-Port $server_port;
21
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
22
+ proxy_pass http://rancherserver;
23
+ proxy_http_version 1.1;
24
+ proxy_set_header Upgrade $http_upgrade;
25
+ proxy_set_header Connection "upgrade";
26
+ # This allows the ability for the execute shell window to remain open for up to 15 minutes. Without this parameter, the default is 1 minute and will automatically close.
27
+ proxy_read_timeout 900s;
28
+ }
29
+ }
30
+
31
+ server {
32
+ listen 80;
33
+ server_name ${RANCHER_URL};
34
+ return 301 https://$server_name$request_uri;
35
+ }
You can’t perform that action at this time.
0 commit comments