https proxy + redirects
This commit is contained in:
@@ -28,10 +28,8 @@ class General extends Component
|
||||
public bool $is_git_lfs_allowed;
|
||||
public bool $is_debug;
|
||||
public bool $is_previews;
|
||||
public bool $is_custom_ssl;
|
||||
public bool $is_http2;
|
||||
public bool $is_auto_deploy;
|
||||
public bool $is_dual_cert;
|
||||
public bool $is_force_https;
|
||||
|
||||
protected $rules = [
|
||||
'application.name' => 'required|min:6',
|
||||
@@ -57,10 +55,8 @@ class General extends Component
|
||||
$this->application->settings->is_git_lfs_allowed = $this->is_git_lfs_allowed;
|
||||
$this->application->settings->is_debug = $this->is_debug;
|
||||
$this->application->settings->is_previews = $this->is_previews;
|
||||
$this->application->settings->is_custom_ssl = $this->is_custom_ssl;
|
||||
$this->application->settings->is_http2 = $this->is_http2;
|
||||
$this->application->settings->is_auto_deploy = $this->is_auto_deploy;
|
||||
$this->application->settings->is_dual_cert = $this->is_dual_cert;
|
||||
$this->application->settings->is_force_https = $this->is_force_https;
|
||||
$this->application->settings->save();
|
||||
$this->application->refresh();
|
||||
$this->emit('saved', 'Application settings updated!');
|
||||
@@ -80,10 +76,8 @@ class General extends Component
|
||||
$this->is_git_lfs_allowed = $this->application->settings->is_git_lfs_allowed;
|
||||
$this->is_debug = $this->application->settings->is_debug;
|
||||
$this->is_previews = $this->application->settings->is_previews;
|
||||
$this->is_custom_ssl = $this->application->settings->is_custom_ssl;
|
||||
$this->is_http2 = $this->application->settings->is_http2;
|
||||
$this->is_auto_deploy = $this->application->settings->is_auto_deploy;
|
||||
$this->is_dual_cert = $this->application->settings->is_dual_cert;
|
||||
$this->is_force_https = $this->application->settings->is_force_https;
|
||||
$this->checkWildCardDomain();
|
||||
}
|
||||
public function generateGlobalRandomDomain()
|
||||
|
||||
@@ -48,7 +48,6 @@ class DeployApplicationJob implements ShouldQueue
|
||||
public string $application_uuid,
|
||||
public bool $force_rebuild = false,
|
||||
) {
|
||||
|
||||
$this->application = Application::query()
|
||||
->where('uuid', $this->application_uuid)
|
||||
->firstOrFail();
|
||||
@@ -388,14 +387,34 @@ COPY --from={$this->application->uuid}:{$this->git_commit}-build /app/{$this->ap
|
||||
$url = Url::fromString($domain);
|
||||
$host = $url->getHost();
|
||||
$path = $url->getPath();
|
||||
$slug = Str::slug($url);
|
||||
$label_id = "{$this->application->uuid}-{$slug}";
|
||||
if ($path === '/') {
|
||||
$labels[] = "traefik.http.routers.{$label_id}.rule=Host(`{$host}`) && PathPrefix(`{$path}`)";
|
||||
} else {
|
||||
$labels[] = "traefik.http.routers.{$label_id}.rule=Host(`{$host}`) && PathPrefix(`{$path}`)";
|
||||
$labels[] = "traefik.http.routers.{$label_id}.middlewares={$label_id}-stripprefix";
|
||||
$labels[] = "traefik.http.middlewares.{$label_id}-stripprefix.stripprefix.prefixes={$path}";
|
||||
$schema = $url->getScheme();
|
||||
$slug = Str::slug($host . $path);
|
||||
|
||||
$http_label = "{$this->application->uuid}-{$slug}-http";
|
||||
$https_label = "{$this->application->uuid}-{$slug}-https";
|
||||
|
||||
// Set labels for http
|
||||
$labels[] = "traefik.http.routers.{$http_label}.rule=Host(`{$host}`) && PathPrefix(`{$path}`)";
|
||||
$labels[] = "traefik.http.routers.{$http_label}.middlewares=gzip";
|
||||
if ($path !== '/') {
|
||||
$labels[] = "traefik.http.routers.{$http_label}.middlewares={$http_label}-stripprefix";
|
||||
$labels[] = "traefik.http.middlewares.{$http_label}-stripprefix.stripprefix.prefixes={$path}";
|
||||
}
|
||||
|
||||
// Set labels for https
|
||||
if ($schema === 'https') {
|
||||
$labels[] = "traefik.http.routers.{$https_label}.rule=Host(`{$host}`) && PathPrefix(`{$path}`)";
|
||||
$labels[] = "traefik.http.routers.{$https_label}.middlewares=gzip";
|
||||
if ($path !== '/') {
|
||||
$labels[] = "traefik.http.routers.{$https_label}.middlewares={$https_label}-stripprefix";
|
||||
$labels[] = "traefik.http.middlewares.{$https_label}-stripprefix.stripprefix.prefixes={$path}";
|
||||
}
|
||||
|
||||
$labels[] = "traefik.http.routers.{$https_label}.tls=true";
|
||||
$labels[] = "traefik.http.routers.{$https_label}.tls.certresolver=letsencrypt";
|
||||
if ($this->application->settings->is_force_https) {
|
||||
$labels[] = "traefik.http.routers.{$http_label}.middlewares=redirect-to-https";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user