235 in active_services:iter(service, nil, nil, nil) do |
235 in active_services:iter(service, nil, nil, nil) do |
236 if active_service.server.hosts and active_service.tls_cfg then |
236 if active_service.server.hosts and active_service.tls_cfg then |
237 local config_prefix = (active_service.config_prefix or name).."_"; |
237 local config_prefix = (active_service.config_prefix or name).."_"; |
238 if config_prefix == "_" then config_prefix = ""; end |
238 if config_prefix == "_" then config_prefix = ""; end |
239 local prefix_ssl_config = config.get(host, config_prefix.."ssl"); |
239 local prefix_ssl_config = config.get(host, config_prefix.."ssl"); |
240 local autocert = certmanager.find_host_cert(host); |
240 local alternate_host = service and config.get(host, service.."_host"); |
|
241 local autocert = certmanager.find_host_cert(alternate_host or host); |
241 -- luacheck: ignore 211/cfg |
242 -- luacheck: ignore 211/cfg |
242 local ssl, err, cfg = certmanager.create_context(host, "server", prefix_ssl_config, autocert, active_service.tls_cfg); |
243 local ssl, err, cfg = certmanager.create_context(host, "server", prefix_ssl_config, autocert, active_service.tls_cfg); |
243 if ssl then |
244 if ssl then |
244 active_service.server.hosts[host] = ssl; |
245 active_service.server.hosts[alternate_host or host] = ssl; |
245 else |
246 else |
246 log("error", "Error creating TLS context for SNI host %s: %s", host, err); |
247 log("error", "Error creating TLS context for SNI host %s: %s", host, err); |
247 end |
248 end |
248 end |
249 end |
249 end |
250 end |