λλ©μΈ μ ν¨μ± κ²μ¬λ₯Ό μννκΈ° μν΄ μΉ μλΉμ€λ₯Ό ꡬννμ΅λλ€. μ°λ¦¬κ° κΆκΈν κ²μ allow_domain
λ©μλμμ μΉ μμ²μ λ°νν λμ μ±λ₯ μν₯μ
λλ€. λν μ΄ λ©μλλ μΌλ§λ μμ£Ό νΈμΆλ©λκΉ? Let's Encrypt μνμ€ μ§μ μλ§ νΈμΆλ©λκΉ?
allow_domain
λ₯Ό νΈμΆν νμκ° μλ μ μ₯μμ λλ©μΈμ λν μΈμ¦μκ° μλ κ²μ²λΌ λ³΄μΌ κ²μ
λλ€.
μλ§λ μ΄λ¬ν μ νμ μ€λͺ μ΄ λ¬Έμμμ λ μ μ©ν κ²μ λλ€.
κ°μ¬ν©λλ€.
μΈμ¦μκ° μλμ§ μ¬λΆλ₯Ό νΈμΆν©λλ€. κ°μΈμ μΌλ‘ μ λ λ°±μλμ μ μΈμ¦μλ₯Ό μμ±ν΄λ λλμ§ λ¬»κΈ° μ μ μ΄λ―Έ μΈμ¦μκ° μλμ§ νμΈν©λλ€.
-- first check if we have the certificate already, else check with backend if we allow it
local certstorage = auto_ssl:get("storage")
local fullchain_pem, privkey_pem = certstorage:get_cert(domain)
if fullchain_pem then
return true
else ...
μ€λ²ν€λ/μ±λ₯ μν₯μ λν΄μλ μ½κ° μ°λ €νκ³ μμ§λ§ μμ§ κ³ν λ¨κ³μ μμΌλ©° μμ§κΉμ§λ λ¬μ±νμ§ λͺ»νμ΅λλ€.
@brianlund 곡μ lua_shared_dict
λ₯Ό ꡬννμ΅λλ€.
auto_ssl:set("allow_domain", function(domain)
local http = require "resty.http"
local httpc = http.new()
local cjson = require "cjson"
local our_allow_domain_cache = ngx.shared.our_allow_domain_cache
local found = our_allow_domain_cache:get(domain)
if found == nil then
local res, err = httpc:request_uri("[is domain allowed web service]"..domain, {
method = "GET",
})
if not res then
found = false
else
local data = cjson.decode(res.body)
found = data.found
end
-- Cache for 60 seconds, for now...
our_allow_domain_cache:set(domain, found, 60)
else
if found then
-- Known good domain, keep it in cache for a little longer
our_allow_domain_cache:set(domain, found, 300)
end
end
auto_ssl:get("storage")
μλΉμ€λ₯Ό νμΈνλ λΉμ μ μμ΄λμ΄κ° μ λ§ λ§μμ λλλ€. λλ λΉμ·ν κ²μ κ°μ§κ³ κ° μ μμ΅λλ€. μ΄κ²μ΄ λͺ¨λ μμ²μμ λ°μνλ€κ³ κ°μ ν μ μμ΅λκΉ? μλλ©΄ lua_shared_dict auto_ssl
κ° μ μ₯μ© μΊμ± λ μ΄μ΄λ‘ μ¬μ©λκ³ μμ΅λκΉ? λ€μκ³Ό κ°μ μ μμ΅λλ€. https://github.com/GUI/lua-resty-auto-ssl/blob/master/lib/resty/auto-ssl/ssl_certificate.lua#L20
κ·νμ μμμ λ€μμ νμΈνλ κ²μ΄ λ λμμ§ κΆκΈν©λλ€.
ngx.shared.auto_ssl:get("domain:fullchain_der:" .. domain)
λ storage
μ§μ νΈμΆ.
ngx.shared.auto_ssl:get("domain:fullchain_der:" .. domain)
λ 곡μ λ©λͺ¨λ¦¬ μΊμλ§ νμΈν©λλ€. μ¬λ¬ λ
Έλλ₯Ό μ€νν κ³νμ΄λ―λ‘ λ
Έλ κ°μ 곡μ ν μ μλ νλͺ©(redis μ€ν 리μ§)μ΄ νμν©λλ€. νμ§λ§ μΊμ μ루μ
μ΄ λ§μμ λλλ€. μ€ν λ¦¬μ§ μλΉμ€μ λν λ§μ νΈμΆμ μ μ½ν μ μμ΅λλ€. μμ£Ό νΈμΆνλ λ° λ¬Έμ κ° μλ κ²½μ° μ΄λ₯Ό μΌλμ λκ² μ΅λλ€.
λ°λͺ¨ μ½λλ₯Ό μ κ³΅ν΄ μ£Όμ μ νκ³ μΆμ΅λλ€. μ΄κ²μ μ μκ² λ§€μ° μ μ©ν κ΅¬μ± μμμμ΅λλ€! κ°μ¬ν©λλ€!
μ΄κ²μ΄ λͺ¨λ μμ²μμ λ°μνλ€κ³ κ°μ ν μ μμ΅λκΉ?
μ΄κ²μ μ λ§ μ’μ μ§λ¬Έμ λλ€.
λ΄ κ°μ μ μ΄ λ©μλκ° λλ©μΈμ λν μΈμ¦μκ° μμ λ νΈμΆλμ§λ§ νμ€νμ§ μμ΅λλ€.
@jasonbouffard νμΈ
@Alir3z4
μ λ μ΄κ² κΆκΈνμ΅λλ€.
λ¬Έμλ μ΄μ λν΄ ν¬λͺ
νμ§ μμΌλ―λ‘ μμ€ μ½λλ₯Ό κ²μ¬ν΄μΌ νμ΅λλ€.
λ°λΌμ λͺ¨λ μμ²μμ auto-sslμ λ€μμ μνν©λλ€.
ngx.shared.auto_ssl
μ¬μ μμ μΈμ¦μλ₯Ό κ°μ Έμ€λ €κ³ ν©λλ€.allow_domain
λ©μλ νΈμΆREADME.mdμμ μ΄κ²μ μ€λͺ
νλ κ²μ΄ μλ²½ν κ²μ
λλ€.
κ°μ¬ ν΄μ!
μΆμ²: