Skip to content

Commit

Permalink
add basic redis
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianmacarescu committed May 25, 2020
1 parent cfca129 commit 884cbcc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sh text eol=lf
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ ENV DIFFIE_HELLMAN='' \
FORCE_HTTPS='true' \
SITES='' \
LETSENCRYPT_URL='https://acme-v02.api.letsencrypt.org/directory' \
STORAGE_ADAPTER='file' \
REDIS_HOST='' \
REDIS_DB='' \
REDIS_KEY_PREFIX='' \
RESOLVER_ADDRESS='8.8.8.8'

# Here we install open resty and generate dhparam.pem file.
Expand Down
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fi


# let's substitute $ALLOWED_DOMAINS, $LETSENCRYPT_URL and $RESOLVER_ADDRESS into OpenResty configuration
envsubst '$ALLOWED_DOMAINS,$LETSENCRYPT_URL,$RESOLVER_ADDRESS' \
envsubst '$ALLOWED_DOMAINS,$LETSENCRYPT_URL,$RESOLVER_ADDRESS,$STORAGE_ADAPTER,$REDIS_HOST,$REDIS_DB,$REDIS_KEY_PREFIX' \
< ${RESTY_CONF_DIR}/resty-http.conf \
> ${RESTY_CONF_DIR}/resty-http.conf.copy \
&& mv ${RESTY_CONF_DIR}/resty-http.conf.copy ${RESTY_CONF_DIR}/resty-http.conf
Expand Down
11 changes: 10 additions & 1 deletion snippets/resty-http.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# The "auto_ssl" shared dict should be defined with enough storage space to
# hold your certificate data. 1MB of storage holds certificates for
# approximately 100 separate domains.
lua_shared_dict auto_ssl 1m;
lua_shared_dict auto_ssl 10m;

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

if "$STORAGE_ADAPTER" == "redis" then
auto_ssl:set("storage_adapter", "resty.auto-ssl.storage_adapters.redis")
auto_ssl:set("redis", {
host = "$REDIS_HOST",
db = "$REDIS_DB",
prefix = "$REDIS_KEY_PREFIX"
})
end

auto_ssl:init()
}

Expand Down

0 comments on commit 884cbcc

Please sign in to comment.