@@ -85,9 +85,20 @@ func acmeRegisterSpecialRoutingRule() {
85
85
// This function check if the renew setup is satisfied. If not, toggle them automatically
86
86
func AcmeCheckAndHandleRenewCertificate (w http.ResponseWriter , r * http.Request ) {
87
87
isForceHttpsRedirectEnabledOriginally := false
88
+ requireRestorePort80 := false
88
89
dnsPara , _ := utils .PostBool (r , "dns" )
89
90
if ! dnsPara {
91
+
90
92
if dynamicProxyRouter .Option .Port == 443 {
93
+ //Check if port 80 is enabled
94
+ if ! dynamicProxyRouter .Option .ListenOnPort80 {
95
+ //Enable port 80 temporarily
96
+ SystemWideLogger .PrintAndLog ("ACME" , "Temporarily enabling port 80 listener to handle ACME request " , nil )
97
+ dynamicProxyRouter .UpdatePort80ListenerState (true )
98
+ requireRestorePort80 = true
99
+ time .Sleep (2 * time .Second )
100
+ }
101
+
91
102
//Enable port 80 to 443 redirect
92
103
if ! dynamicProxyRouter .Option .ForceHttpsRedirect {
93
104
SystemWideLogger .Println ("Temporary enabling HTTP to HTTPS redirect for ACME certificate renew requests" )
@@ -107,8 +118,8 @@ func AcmeCheckAndHandleRenewCertificate(w http.ResponseWriter, r *http.Request)
107
118
}
108
119
}
109
120
110
- //Add a 3 second delay to make sure everything is settle down
111
- time .Sleep (3 * time .Second )
121
+ //Add a 2 second delay to make sure everything is settle down
122
+ time .Sleep (2 * time .Second )
112
123
113
124
// Pass over to the acmeHandler to deal with the communication
114
125
acmeHandler .HandleRenewCertificate (w , r )
@@ -117,13 +128,17 @@ func AcmeCheckAndHandleRenewCertificate(w http.ResponseWriter, r *http.Request)
117
128
tlsCertManager .UpdateLoadedCertList ()
118
129
119
130
//Restore original settings
120
- if dynamicProxyRouter .Option .Port == 443 && ! dnsPara {
121
- if ! isForceHttpsRedirectEnabledOriginally {
122
- //Default is off. Turn the redirection off
123
- SystemWideLogger .PrintAndLog ("ACME" , "Restoring HTTP to HTTPS redirect settings" , nil )
124
- dynamicProxyRouter .UpdateHttpToHttpsRedirectSetting (false )
125
- }
131
+ if requireRestorePort80 {
132
+ //Restore port 80 listener
133
+ SystemWideLogger .PrintAndLog ("ACME" , "Restoring previous port 80 listener settings" , nil )
134
+ dynamicProxyRouter .UpdatePort80ListenerState (false )
135
+ }
136
+ if ! isForceHttpsRedirectEnabledOriginally {
137
+ //Default is off. Turn the redirection off
138
+ SystemWideLogger .PrintAndLog ("ACME" , "Restoring HTTP to HTTPS redirect settings" , nil )
139
+ dynamicProxyRouter .UpdateHttpToHttpsRedirectSetting (false )
126
140
}
141
+
127
142
}
128
143
129
144
// HandleACMEPreferredCA return the user preferred / default CA for new subdomain auto creation
0 commit comments