Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Docker Nginx Auto Ssl
Commits
1f2852cc
"app/vscode:/vscode.git/clone" did not exist on "fc94439b74ee82888594ccb31bf4afcd1d04a879"
Commit
1f2852cc
authored
Dec 18, 2017
by
Valian
Browse files
changed BACKEND variable to SITES
parent
e0d27d99
Changes
2
Show whitespace changes
Inline
Side-by-side
entrypoint.sh
View file @
1f2852cc
...
...
@@ -16,33 +16,33 @@ if [ ! -f "/etc/resty-auto-ssl/dhparam.pem" ]; then
fi
# if $
BACKEND
S is defined, we should prepare configuration files
# if $
SITE
S is defined, we should prepare configuration files
# example usage:
#
# -e
BACKEND
S="db.example.com=localhost:5432;app.example.com=http://localhost:8080"
# -e
SITE
S="db.example.com=localhost:5432;app.example.com=http://localhost:8080"
#
# it will create 2 files:
#
# 1. /etc/nginx/conf.d/db.example.com.conf using $SERVER_ENDPOINT=localhost:5432 and $SERVER_NAME=db.example.com
# 2. /etc/nginx/conf.d/app.example.com.conf using $SERVER_ENDPOINT=localhost:8080 and $SERVER_NAME=app.example.com
if
[
-n
"
$
BACKEND
S
"
]
;
then
if
[
-n
"
$
SITE
S
"
]
;
then
# lets read all backends, separated by ';'
IFS
=
\;
read
-a
BACKEND
S_SEPARATED
<<<
"
$
BACKEND
S
"
IFS
=
\;
read
-a
SITE
S_SEPARATED
<<<
"
$
SITE
S
"
# for each backend (in form of server_name=endpoint:port) we create proper file
for
NAME_EQ_ENDPOINT
in
"
${
BACKEND
S_SEPARATED
[@]
}
"
;
do
for
NAME_EQ_ENDPOINT
in
"
${
SITE
S_SEPARATED
[@]
}
"
;
do
RAW_SERVER_ENDPOINT
=
${
NAME_EQ_ENDPOINT
#*=
}
export
SERVER_NAME
=
${
NAME_EQ_ENDPOINT
%=*
}
export
SERVER_ENDPOINT
=
${
RAW_SERVER_ENDPOINT
#*//
}
# it clears url scheme, like http:// or https://
envsubst
'$SERVER_NAME $SERVER_ENDPOINT'
\
<
${
RESTY_CONF_DIR
}
/server-
backend
.conf
\
<
${
RESTY_CONF_DIR
}
/server-
proxy
.conf
\
>
${
NGINX_CONF_DIR
}
/
${
SERVER_NAME
}
.conf
done
unset
SERVER_NAME SERVER_ENDPOINT
# if $
BACKEND
S isn't defined, let's check if $NGINX_CONF_DIR is empty
# if $
SITE
S isn't defined, let's check if $NGINX_CONF_DIR is empty
elif
[
!
"
$(
ls
-A
${
NGINX_CONF_DIR
}
)
"
]
;
then
# if yes, just copy default server (similar to default from docker-openresty, but using https)
cp
${
RESTY_CONF_DIR
}
/server-default.conf
${
NGINX_CONF_DIR
}
/default.conf
...
...
snippets/server-
backend
.conf
→
snippets/server-
proxy
.conf
View file @
1f2852cc
# this configuration will be used for each server
# specified using $
BACKEND
S variable
# specified using $
SITE
S variable
# more in README
server
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment