@@ -50,18 +50,24 @@ local function ssl_listen(host, port, options)
5050end
5151
5252local function start_ssl (self )
53- self .server = http_server_lib .new (self .options .host , self .options .port443 )
54- self .server .cert_full_name = self .cert_full_name
53+ if (self .ssl_enable ) then
54+ self .redirect = https_redirect_lib .new ()
55+ self .redirect :start (self .options .host , self .options .port80 )
56+
57+ self .server = http_server_lib .new (self .options .host , self .options .port443 )
58+ self .server .tcp_server_f = ssl_listen
59+ self .server .cert_full_name = self .cert_full_name
60+
61+ self .ssl_active = true
62+ else
63+ self .server = http_server_lib .new (self .options .host , self .options .port80 )
64+ end
5565
5666 for _ , tuple in ipairs (self .route_table ) do
5767 self .server :route (tuple .options , tuple .proc )
5868 end
5969
60- self .server .tcp_server_f = ssl_listen
6170 self .server :start ()
62- self .redirect = https_redirect_lib .new ()
63- self .redirect :start (self .options .host , self .options .port80 )
64- self .ssl_active = true
6571end
6672
6773local function stop_ssl (self )
@@ -89,16 +95,19 @@ local function setup_challenge_proc(self)
8995end
9096
9197local function start (self )
92- update_valid_to (self )
9398
94- if self .cert_need_reissue then
95- self .server = http_server_lib .new (self .options .host , self .options .port80 )
96- self .server :start ()
97- local proc = setup_challenge_proc (self )
98- local acme_client = acme_lib .new (self .options , proc )
99- acme_client :getCert ()
100- self .server :stop ()
99+ if self .ssl_enable then
101100 update_valid_to (self )
101+
102+ if self .cert_need_reissue then
103+ self .server = http_server_lib .new (self .options .host , self .options .port80 )
104+ self .server :start ()
105+ local proc = setup_challenge_proc (self )
106+ local acme_client = acme_lib .new (self .options , proc )
107+ acme_client :getCert ()
108+ self .server :stop ()
109+ update_valid_to (self )
110+ end
102111 end
103112
104113 start_ssl (self )
@@ -130,6 +139,7 @@ local exports = {
130139 start = start ,
131140 stop = stop ,
132141 schedule = schedule ,
142+ ssl_enable = options .ssl ~= false
133143 }
134144
135145 self .options .internalIP4 = options .host or options .internalIP4
0 commit comments