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
Commits
b57520e1
Commit
b57520e1
authored
Jun 13, 2022
by
name
Browse files
优化启动脚本
parent
afbf46c8
Changes
2
Show whitespace changes
Inline
Side-by-side
Dockerfile
View file @
b57520e1
...
...
@@ -12,7 +12,6 @@ RUN set -ex \
&&
rm
-rf
/acme_src /var/cache/apk/
*
\
&&
mkdir
/etc/nginx/ssl
\
&&
mkdir
/etc/nginx/ssl/app
\
&&
mkdir
/etc/nginx/ssl/default
COPY
./nginx.conf /etc/nginx/nginx.conf
COPY
./default.conf /etc/nginx/conf.d/default.conf
...
...
docker-entrypoint.sh
View file @
b57520e1
...
...
@@ -4,25 +4,24 @@
DOMAINS
=
$(
echo
"
$DOMAINS
"
|
tr
-s
' '
)
SslServer
=
"
$SslServer
"
mail
=
"
$mail
"
SSL_DIR
=
"/etc/nginx/ssl/app/"
if
[
-z
"
$DOMAINS
"
]
;
then
echo
"[
$(
date
)
] Empty env var DOMAINS"
# exit 1
fi
mkdir
-p
/etc/nginx/ssl/default/
mkdir
-p
/etc/nginx/ssl/app/
mkdir
-p
${
SSL_DIR
}
/
function
CreateDefault
()
{
if
[
-e
"
/etc/nginx/ssl/app
/cert.pem"
]
;
then
if
[
-e
"
${
SSL_DIR
}
/cert.pem"
]
;
then
echo
"[
$(
date
)
] default cert exists"
else
openssl req
-x509
-newkey
rsa:4096
-nodes
-days
365
\
-subj
"/C=CA/ST=QC/O=Company Inc/CN=example.com"
\
-out
/etc/nginx/ssl/default/cert.pem
\
-keyout
/etc/nginx/ssl/default/key.pem
cp
/etc/nginx/ssl/default/
*
.pem /etc/nginx/ssl/app/
chmod
+w /etc/nginx/ssl/app/
*
-out
${
SSL_DIR
}
/cert.pem
\
-keyout
${
SSL_DIR
}
/key.pem
chmod
+w
${
SSL_DIR
}
/
*
fi
}
...
...
@@ -59,9 +58,9 @@ function StartAcmesh() {
echo
"[
$(
date
)
] acme.sh install-cert .."
/root/.acme.sh/acme.sh
--install-cert
$ACME_DOMAIN_OPTION
\
--fullchain-file
/etc/nginx/ssl/app
/fullchain.pem
\
--cert-file
/etc/nginx/ssl/app
/cert.pem
\
--key-file
/etc/nginx/ssl/app
/key.pem
\
--fullchain-file
${
SSL_DIR
}
/fullchain.pem
\
--cert-file
${
SSL_DIR
}
/cert.pem
\
--key-file
${
SSL_DIR
}
/key.pem
\
--reloadcmd
"nginx -s reload"
echo
"[
$(
date
)
] Start cron"
...
...
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