auto-ssl / lua-resty-auto-ssl

On the fly (and free) SSL registration and renewal inside OpenResty/nginx with Let's Encrypt.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

allow_domains on redis storage

shimsag opened this issue · comments

Hi ,

I developed a multi-tenancy application which allows my tenants to use their arbitrary domains (in addition to the subdomain I provide).

We will use redis storage adapter for ssl certificates generated by resty-auto-ssl but I would also like to make a whitelist of domains on my redis server instead of a txt file.

Is it possible ? Can anyone show me an example of how it should be done ?

we've used this :

 auto_ssl:set("allow_domain", function(domain, auto_ssl, ssl_options, renewal)
        
        local redis_instance, instance_err = auto_ssl.storage.adapter:get_connection()
            if instance_err then
                return nil, instance_err
            end
         --  if there's a key in redis "www.foo.bar" with any value, allow it
        local res, err = redis_instance:get(domain)
        
        if res == ngx.null then
          return false
        else
          return true
        end
    end)

we've used this :

 auto_ssl:set("allow_domain", function(domain, auto_ssl, ssl_options, renewal)
        
        local redis_instance, instance_err = auto_ssl.storage.adapter:get_connection()
            if instance_err then
                return nil, instance_err
            end
         --  if there's a key in redis "www.foo.bar" with any value, allow it
        local res, err = redis_instance:get(domain)
        
        if res == ngx.null then
          return false
        else
          return true
        end
    end)

Thank you so much !!