From dcffda98152cd3e1230b67bd13ccd9ea9b6768b5 Mon Sep 17 00:00:00 2001 From: Gerald H Date: Tue, 15 May 2018 14:24:11 +0200 Subject: [PATCH 1/6] Added --force flag to some artisan commands. This enables an automatic 'composer install' command in production environments. --- composer.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 76d67f3f..2aa81ea0 100644 --- a/composer.json +++ b/composer.json @@ -41,10 +41,10 @@ "post-install-cmd": [ "php artisan optimize", "php artisan migrate:install", - "php artisan migrate", - "php artisan migrate --package=cartalyst/sentry", - "php artisan db:seed", - "php artisan migrate --package=tdt/input", + "php artisan migrate --force", + "php artisan migrate --package=cartalyst/sentry --force", + "php artisan db:seed --force", + "php artisan migrate --package=tdt/input --force", "php artisan asset:publish tdt/input", "php artisan config:publish tdt/input" ], @@ -53,8 +53,8 @@ ], "post-update-cmd": [ "php artisan optimize", - "php artisan migrate", - "php artisan migrate --package=cartalyst/sentry" + "php artisan migrate --force", + "php artisan migrate --package=cartalyst/sentry --force" ], "post-create-project-cmd": [ "php artisan key:generate" From 99fe183d41a77012c5832b113787e028fb43d495 Mon Sep 17 00:00:00 2001 From: Gerald Haesendonck Date: Wed, 1 Aug 2018 11:55:37 +0200 Subject: [PATCH 2/6] Try to configure reverse proxy handling --- app/Tdt/Core/Proxy/ProxyServiceProvider.php | 33 +++++++++++++++++++++ app/config/app.php | 1 + app/config/proxy.php | 18 +++++++++++ 3 files changed, 52 insertions(+) create mode 100644 app/Tdt/Core/Proxy/ProxyServiceProvider.php create mode 100644 app/config/proxy.php diff --git a/app/Tdt/Core/Proxy/ProxyServiceProvider.php b/app/Tdt/Core/Proxy/ProxyServiceProvider.php new file mode 100644 index 00000000..91770270 --- /dev/null +++ b/app/Tdt/Core/Proxy/ProxyServiceProvider.php @@ -0,0 +1,33 @@ +app['request']; + $proxies = $this->app['config']->get('proxy.proxies'); + + if( $proxies === '*' ) { + // Trust all proxies - proxy is whatever + // the current client IP address is + $proxies = array( $request->getClientIp() ); + } + $request->setTrustedProxies( $proxies ); + } + +} diff --git a/app/config/app.php b/app/config/app.php index cd8dbc98..7ed22e56 100644 --- a/app/config/app.php +++ b/app/config/app.php @@ -123,6 +123,7 @@ 'Tdt\Core\Repositories\DbServiceProvider', 'Tdt\Core\Analytics\TrackerServiceProvider', 'Tdt\Input\InputServiceProvider', + 'Tdt\Core\Proxy\ProxyServiceProvider', ), /* diff --git a/app/config/proxy.php b/app/config/proxy.php new file mode 100644 index 00000000..2ace17ba --- /dev/null +++ b/app/config/proxy.php @@ -0,0 +1,18 @@ + '*' + | + */ + + 'proxies' => '*' +); From da03e624bffecdee217ffa354523a295e48c214e Mon Sep 17 00:00:00 2001 From: Gerald Haesendonck Date: Wed, 1 Aug 2018 12:55:17 +0200 Subject: [PATCH 3/6] Forgot namespace of ServiceProvider --- app/Tdt/Core/Proxy/ProxyServiceProvider.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Tdt/Core/Proxy/ProxyServiceProvider.php b/app/Tdt/Core/Proxy/ProxyServiceProvider.php index 91770270..0c960eac 100644 --- a/app/Tdt/Core/Proxy/ProxyServiceProvider.php +++ b/app/Tdt/Core/Proxy/ProxyServiceProvider.php @@ -1,4 +1,8 @@ - Date: Wed, 1 Aug 2018 17:15:32 +0200 Subject: [PATCH 4/6] read external config --- app/routes.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/app/routes.php b/app/routes.php index 2cfa7d84..bfcd1a79 100755 --- a/app/routes.php +++ b/app/routes.php @@ -6,6 +6,27 @@ |-------------------------------------------------------------------------- */ +/** + * First a hack that enables configuring TDT to live behind a proxy + */ + +// we read a .env file as would be the case with Laravel 5 +$env_file = dirname(__FILE__) . '/.env'; + +// parse this as properties defined in the .env file +$properties = parse_ini_file($env_file); + +$proxy_url = $properties['PROXY_URL']; +$proxy_schema = $properties['PROXY_SCHEMA']; + +if (!empty($proxy_url)) { + URL::forceRootUrl($proxy_url); +} + +if (!empty($proxy_schema)) { + $proxy_schema = getenv('PROXY_SCHEMA'); +} + /** * Admin routes */ From 37d46b6a8828290379d5730b7e43b07b30f93499 Mon Sep 17 00:00:00 2001 From: Gerald H Date: Thu, 2 Aug 2018 10:43:55 +0200 Subject: [PATCH 5/6] Comment out code for future use --- app/routes.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/routes.php b/app/routes.php index bfcd1a79..410b2e6d 100755 --- a/app/routes.php +++ b/app/routes.php @@ -14,7 +14,7 @@ $env_file = dirname(__FILE__) . '/.env'; // parse this as properties defined in the .env file -$properties = parse_ini_file($env_file); +/*$properties = parse_ini_file($env_file); $proxy_url = $properties['PROXY_URL']; $proxy_schema = $properties['PROXY_SCHEMA']; @@ -25,7 +25,7 @@ if (!empty($proxy_schema)) { $proxy_schema = getenv('PROXY_SCHEMA'); -} +}*/ /** * Admin routes From 1a8aa45cb499e5e6f87ea5b88d765bf3669a05b3 Mon Sep 17 00:00:00 2001 From: Gerald H Date: Thu, 2 Aug 2018 10:44:38 +0200 Subject: [PATCH 6/6] Comment out code for future use (part 2) --- app/routes.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/routes.php b/app/routes.php index 410b2e6d..0365d895 100755 --- a/app/routes.php +++ b/app/routes.php @@ -11,10 +11,10 @@ */ // we read a .env file as would be the case with Laravel 5 -$env_file = dirname(__FILE__) . '/.env'; +/*$env_file = dirname(__FILE__) . '/.env'; // parse this as properties defined in the .env file -/*$properties = parse_ini_file($env_file); +$properties = parse_ini_file($env_file); $proxy_url = $properties['PROXY_URL']; $proxy_schema = $properties['PROXY_SCHEMA'];