Skip to content

Commit 884cbcc

Browse files
add basic redis
1 parent cfca129 commit 884cbcc

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.sh text eol=lf

Dockerfile

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ ENV DIFFIE_HELLMAN='' \
77
FORCE_HTTPS='true' \
88
SITES='' \
99
LETSENCRYPT_URL='https://acme-v02.api.letsencrypt.org/directory' \
10+
STORAGE_ADAPTER='file' \
11+
REDIS_HOST='' \
12+
REDIS_DB='' \
13+
REDIS_KEY_PREFIX='' \
1014
RESOLVER_ADDRESS='8.8.8.8'
1115

1216
# Here we install open resty and generate dhparam.pem file.

entrypoint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fi
5959

6060

6161
# let's substitute $ALLOWED_DOMAINS, $LETSENCRYPT_URL and $RESOLVER_ADDRESS into OpenResty configuration
62-
envsubst '$ALLOWED_DOMAINS,$LETSENCRYPT_URL,$RESOLVER_ADDRESS' \
62+
envsubst '$ALLOWED_DOMAINS,$LETSENCRYPT_URL,$RESOLVER_ADDRESS,$STORAGE_ADAPTER,$REDIS_HOST,$REDIS_DB,$REDIS_KEY_PREFIX' \
6363
< ${RESTY_CONF_DIR}/resty-http.conf \
6464
> ${RESTY_CONF_DIR}/resty-http.conf.copy \
6565
&& mv ${RESTY_CONF_DIR}/resty-http.conf.copy ${RESTY_CONF_DIR}/resty-http.conf

snippets/resty-http.conf

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# The "auto_ssl" shared dict should be defined with enough storage space to
22
# hold your certificate data. 1MB of storage holds certificates for
33
# approximately 100 separate domains.
4-
lua_shared_dict auto_ssl 1m;
4+
lua_shared_dict auto_ssl 10m;
55

66
# The "auto_ssl" shared dict is used to temporarily store various settings
77
# like the secret used by the hook server on port 8999. Do not change or
@@ -27,6 +27,15 @@ init_by_lua_block {
2727
return ngx.re.match(domain, '$ALLOWED_DOMAINS', 'ijo')
2828
end)
2929

30+
if "$STORAGE_ADAPTER" == "redis" then
31+
auto_ssl:set("storage_adapter", "resty.auto-ssl.storage_adapters.redis")
32+
auto_ssl:set("redis", {
33+
host = "$REDIS_HOST",
34+
db = "$REDIS_DB",
35+
prefix = "$REDIS_KEY_PREFIX"
36+
})
37+
end
38+
3039
auto_ssl:init()
3140
}
3241

0 commit comments

Comments
 (0)