fix
This commit is contained in:
		| @@ -161,110 +161,112 @@ function setup_dynamic_configuration() | |||||||
| { | { | ||||||
|     $dynamic_config_path = get_proxy_path() . "/dynamic"; |     $dynamic_config_path = get_proxy_path() . "/dynamic"; | ||||||
|     $settings = InstanceSettings::get(); |     $settings = InstanceSettings::get(); | ||||||
|     $server = Server::findOrFail(0); |     $server = Server::find(0); | ||||||
|     $file = "$dynamic_config_path/coolify.yaml"; |     if ($server) { | ||||||
|     if (empty($settings->fqdn)) { |         $file = "$dynamic_config_path/coolify.yaml"; | ||||||
|         instant_remote_process([ |         if (empty($settings->fqdn)) { | ||||||
|             "rm -f $file", |             instant_remote_process([ | ||||||
|         ], $server); |                 "rm -f $file", | ||||||
|     } else { |             ], $server); | ||||||
|         $url = Url::fromString($settings->fqdn); |         } else { | ||||||
|         $host = $url->getHost(); |             $url = Url::fromString($settings->fqdn); | ||||||
|         $schema = $url->getScheme(); |             $host = $url->getHost(); | ||||||
|         $traefik_dynamic_conf = [ |             $schema = $url->getScheme(); | ||||||
|             'http' => |             $traefik_dynamic_conf = [ | ||||||
|             [ |                 'http' => | ||||||
|                 'routers' => |  | ||||||
|                 [ |                 [ | ||||||
|                     'coolify-http' => |                     'routers' => | ||||||
|                     [ |                     [ | ||||||
|                         'entryPoints' => [ |                         'coolify-http' => | ||||||
|                             0 => 'http', |  | ||||||
|                         ], |  | ||||||
|                         'service' => 'coolify', |  | ||||||
|                         'rule' => "Host(`{$host}`)", |  | ||||||
|                     ], |  | ||||||
|                     'coolify-realtime-ws' => |  | ||||||
|                     [ |  | ||||||
|                         'entryPoints' => [ |  | ||||||
|                             0 => 'http', |  | ||||||
|                         ], |  | ||||||
|                         'service' => 'coolify-realtime', |  | ||||||
|                         'rule' => "Host(`{$host}`) && PathPrefix(`/app`)", |  | ||||||
|                     ], |  | ||||||
|                 ], |  | ||||||
|                 'services' => |  | ||||||
|                 [ |  | ||||||
|                     'coolify' => |  | ||||||
|                     [ |  | ||||||
|                         'loadBalancer' => |  | ||||||
|                         [ |                         [ | ||||||
|                             'servers' => |                             'entryPoints' => [ | ||||||
|  |                                 0 => 'http', | ||||||
|  |                             ], | ||||||
|  |                             'service' => 'coolify', | ||||||
|  |                             'rule' => "Host(`{$host}`)", | ||||||
|  |                         ], | ||||||
|  |                         'coolify-realtime-ws' => | ||||||
|  |                         [ | ||||||
|  |                             'entryPoints' => [ | ||||||
|  |                                 0 => 'http', | ||||||
|  |                             ], | ||||||
|  |                             'service' => 'coolify-realtime', | ||||||
|  |                             'rule' => "Host(`{$host}`) && PathPrefix(`/app`)", | ||||||
|  |                         ], | ||||||
|  |                     ], | ||||||
|  |                     'services' => | ||||||
|  |                     [ | ||||||
|  |                         'coolify' => | ||||||
|  |                         [ | ||||||
|  |                             'loadBalancer' => | ||||||
|                             [ |                             [ | ||||||
|                                 0 => |                                 'servers' => | ||||||
|                                 [ |                                 [ | ||||||
|                                     'url' => 'http://coolify:80', |                                     0 => | ||||||
|  |                                     [ | ||||||
|  |                                         'url' => 'http://coolify:80', | ||||||
|  |                                     ], | ||||||
|                                 ], |                                 ], | ||||||
|                             ], |                             ], | ||||||
|                         ], |                         ], | ||||||
|                     ], |                         'coolify-realtime' => | ||||||
|                     'coolify-realtime' => |  | ||||||
|                     [ |  | ||||||
|                         'loadBalancer' => |  | ||||||
|                         [ |                         [ | ||||||
|                             'servers' => |                             'loadBalancer' => | ||||||
|                             [ |                             [ | ||||||
|                                 0 => |                                 'servers' => | ||||||
|                                 [ |                                 [ | ||||||
|                                     'url' => 'http://coolify-realtime:6001', |                                     0 => | ||||||
|  |                                     [ | ||||||
|  |                                         'url' => 'http://coolify-realtime:6001', | ||||||
|  |                                     ], | ||||||
|                                 ], |                                 ], | ||||||
|                             ], |                             ], | ||||||
|                         ], |                         ], | ||||||
|                     ], |                     ], | ||||||
|                 ], |                 ], | ||||||
|             ], |  | ||||||
|         ]; |  | ||||||
| 
 |  | ||||||
|         if ($schema === 'https') { |  | ||||||
|             $traefik_dynamic_conf['http']['routers']['coolify-http']['middlewares'] = [ |  | ||||||
|                 0 => 'redirect-to-https@docker', |  | ||||||
|             ]; |             ]; | ||||||
| 
 | 
 | ||||||
|             $traefik_dynamic_conf['http']['routers']['coolify-https'] = [ |             if ($schema === 'https') { | ||||||
|                 'entryPoints' => [ |                 $traefik_dynamic_conf['http']['routers']['coolify-http']['middlewares'] = [ | ||||||
|                     0 => 'https', |                     0 => 'redirect-to-https@docker', | ||||||
|                 ], |                 ]; | ||||||
|                 'service' => 'coolify', |  | ||||||
|                 'rule' => "Host(`{$host}`)", |  | ||||||
|                 'tls' => [ |  | ||||||
|                     'certresolver' => 'letsencrypt', |  | ||||||
|                 ], |  | ||||||
|             ]; |  | ||||||
|             $traefik_dynamic_conf['http']['routers']['coolify-realtime-wss'] = [ |  | ||||||
|                 'entryPoints' => [ |  | ||||||
|                     0 => 'https', |  | ||||||
|                 ], |  | ||||||
|                 'service' => 'coolify-realtime', |  | ||||||
|                 'rule' => "Host(`{$host}`) && PathPrefix(`/app`)", |  | ||||||
|                 'tls' => [ |  | ||||||
|                     'certresolver' => 'letsencrypt', |  | ||||||
|                 ], |  | ||||||
|             ]; |  | ||||||
|         } |  | ||||||
|         $yaml = Yaml::dump($traefik_dynamic_conf, 12, 2); |  | ||||||
|         $yaml = |  | ||||||
|             "# This file is automatically generated by Coolify.\n" . |  | ||||||
|             "# Do not edit it manually (only if you know what are you doing).\n\n" . |  | ||||||
|             $yaml; |  | ||||||
| 
 | 
 | ||||||
|         $base64 = base64_encode($yaml); |                 $traefik_dynamic_conf['http']['routers']['coolify-https'] = [ | ||||||
|         instant_remote_process([ |                     'entryPoints' => [ | ||||||
|             "mkdir -p $dynamic_config_path", |                         0 => 'https', | ||||||
|             "echo '$base64' | base64 -d > $file", |                     ], | ||||||
|         ], $server); |                     'service' => 'coolify', | ||||||
|  |                     'rule' => "Host(`{$host}`)", | ||||||
|  |                     'tls' => [ | ||||||
|  |                         'certresolver' => 'letsencrypt', | ||||||
|  |                     ], | ||||||
|  |                 ]; | ||||||
|  |                 $traefik_dynamic_conf['http']['routers']['coolify-realtime-wss'] = [ | ||||||
|  |                     'entryPoints' => [ | ||||||
|  |                         0 => 'https', | ||||||
|  |                     ], | ||||||
|  |                     'service' => 'coolify-realtime', | ||||||
|  |                     'rule' => "Host(`{$host}`) && PathPrefix(`/app`)", | ||||||
|  |                     'tls' => [ | ||||||
|  |                         'certresolver' => 'letsencrypt', | ||||||
|  |                     ], | ||||||
|  |                 ]; | ||||||
|  |             } | ||||||
|  |             $yaml = Yaml::dump($traefik_dynamic_conf, 12, 2); | ||||||
|  |             $yaml = | ||||||
|  |                 "# This file is automatically generated by Coolify.\n" . | ||||||
|  |                 "# Do not edit it manually (only if you know what are you doing).\n\n" . | ||||||
|  |                 $yaml; | ||||||
| 
 | 
 | ||||||
|         if (config('app.env') == 'local') { |             $base64 = base64_encode($yaml); | ||||||
|             ray($yaml); |             instant_remote_process([ | ||||||
|  |                 "mkdir -p $dynamic_config_path", | ||||||
|  |                 "echo '$base64' | base64 -d > $file", | ||||||
|  |             ], $server); | ||||||
|  | 
 | ||||||
|  |             if (config('app.env') == 'local') { | ||||||
|  |                 ray($yaml); | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Andras Bacsai
					Andras Bacsai