diff --git a/app/Tdt/Core/Proxy/ProxyServiceProvider.php b/app/Tdt/Core/Proxy/ProxyServiceProvider.php new file mode 100644 index 00000000..0c960eac --- /dev/null +++ b/app/Tdt/Core/Proxy/ProxyServiceProvider.php @@ -0,0 +1,37 @@ +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' => '*' +); diff --git a/app/routes.php b/app/routes.php index 2cfa7d84..0365d895 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 */ 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"