auto-ssl / lua-resty-auto-ssl

On the fly (and free) SSL registration and renewal inside OpenResty/nginx with Let's Encrypt.
MIT License
1.94k stars 182 forks source link

allow_domains on redis storage #254

Closed shimsag closed 3 years ago

shimsag commented 3 years ago

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 ?

aviatrix commented 3 years ago

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)
shimsag commented 3 years ago

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 !!