@@ -182,14 +182,6 @@ def verify_installation(self,env):
182182 def setup_caddy (self , domains , env ):
183183 print ("\n Setting up Proxy..." )
184184 try :
185- current_config = None
186- try :
187- response = requests .get ('http://localhost:2019/config/' )
188- if response .status_code == 200 :
189- current_config = response .json ()
190- except requests .exceptions .RequestException :
191- current_config = None
192-
193185 with open ('../helpers/caddy.json' , 'r' ) as f :
194186 config_str = f .read ()
195187 config_str = config_str .replace ('{env.APP_DOMAIN}' , domains ['app_domain' ])
@@ -199,27 +191,6 @@ def setup_caddy(self, domains, env):
199191 config_str = config_str .replace ('{env.APP_REVERSE_PROXY_URL}' , app_reverse_proxy_url )
200192 config_str = config_str .replace ('{env.API_REVERSE_PROXY_URL}' , api_reverse_proxy_url )
201193 new_config = json .loads (config_str )
202-
203- if current_config and 'apps' in current_config and 'http' in current_config ['apps' ] and 'servers' in current_config ['apps' ]['http' ] and 'nixopus' in current_config ['apps' ]['http' ]['servers' ]:
204- new_routes = new_config ['apps' ]['http' ]['servers' ]['nixopus' ].get ('routes' , [])
205- if new_routes :
206- existing_routes = current_config ['apps' ]['http' ]['servers' ]['nixopus' ].get ('routes' , [])
207- env_domains = [domains ['app_domain' ], domains ['api_domain' ]]
208- for route in existing_routes :
209- if any (domain in str (route .get ('match' , [])) for domain in env_domains ):
210- route_id = route .get ('@id' , '' )
211- if route_id :
212- requests .delete (f'http://localhost:2019/config/apps/http/servers/nixopus/routes/{ route_id } ' )
213-
214- response = requests .post (
215- 'http://localhost:2019/config/apps/http/servers/nixopus/routes/...' ,
216- json = new_routes ,
217- headers = {'Content-Type' : 'application/json' }
218- )
219- if response .status_code != 200 :
220- print (f"Failed to update routes: { response .text } " )
221- raise Exception ("Failed to update routes in Caddy configuration" )
222- else :
223194 response = requests .post (
224195 'http://localhost:2019/load' ,
225196 json = new_config ,
@@ -229,7 +200,6 @@ def setup_caddy(self, domains, env):
229200 print ("Failed to create server configuration:" )
230201 print (response .text )
231202 raise Exception ("Failed to create server configuration" )
232-
233203 print ("Caddy configuration loaded successfully" )
234204 except requests .exceptions .RequestException as e :
235205 print (f"Error connecting to Caddy: { str (e )} " )
0 commit comments