diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 3c5fcff984..b7c2def78a 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -32,6 +32,8 @@ class AppServiceProvider extends ServiceProvider Log::getMonolog()->popHandler(); // remove existing errorlog logger Log::useFiles(Config::get('log_file', base_path('logs/librenms.log')), 'error'); + // Set root url according to user's settings + \URL::forceRootUrl(\Config::get('app.url')); // Blade directives (Yucky because of < L5.5) Blade::directive('config', function ($key) { diff --git a/config/app.php b/config/app.php index 6c82768534..ae84631dbb 100644 --- a/config/app.php +++ b/config/app.php @@ -51,7 +51,7 @@ return [ | */ - 'url' => env('APP_URL', 'http://localhost'), + 'url' => env('APP_URL'), /* |-------------------------------------------------------------------------- diff --git a/doc/Support/Environment-Variables.md b/doc/Support/Environment-Variables.md index 854acd796d..d3f241f4ba 100644 --- a/doc/Support/Environment-Variables.md +++ b/doc/Support/Environment-Variables.md @@ -19,6 +19,7 @@ DB_SOCKET= ## Trusted Reverse Proxies A comma separated list of trusted reverse proxy IPs or CIDR. + For legacy reasons the default is `'*'`, which means any proxy is allowed. `'**'` means trust any proxy up the chain. @@ -26,6 +27,18 @@ For legacy reasons the default is `'*'`, which means any proxy is allowed. APP_TRUSTED_PROXIES=192.168.1.0/24,192.167.8.20 ``` +## Base url + +Set the base url for generated urls. Do not set this if it is not needed. + +You may need to set this when using reverse proxies combined with a subdirectory. + +Generally, LibreNMS will make correct URLs (especially if you have set up your proxy variables correctly) + +```dotenv +APP_URL=http://librenms/ +``` + ## User / Group The user and group that LibreNMS should operate as. diff --git a/doc/Support/FAQ.md b/doc/Support/FAQ.md index 9e0801961e..8f78579527 100644 --- a/doc/Support/FAQ.md +++ b/doc/Support/FAQ.md @@ -388,5 +388,8 @@ At a minimum: X-Forwarded-For and X-Forwarded-Proto (X-Forwarded-Port if needed) You also need to [Set the proxy or proxies as trusted](../Support/Environment-Variables.md#trusted-reverse-proxies) +If you are using a subdirectory on the reverse proxy and not on the actual web server, +you may need to set [APP_URL](../Support/Environment-Variables.md#base-url) and `$config['base_url']`. + ### My alerts aren't being delivered on time If you're running MySQL/MariaDB on a separate machine or container make sure the timezone is set properly on both the LibreNMS **and** MySQL/MariaDB instance. Alerts will be delivered according to MySQL/MariaDB's time, so a mismatch between the two can cause alerts to be delivered late if LibreNMS is on a timezone later than MySQL/MariaDB. diff --git a/resources/views/auth/2fa.blade.php b/resources/views/auth/2fa.blade.php index 649077db5b..e31ebc0e4c 100644 --- a/resources/views/auth/2fa.blade.php +++ b/resources/views/auth/2fa.blade.php @@ -1,7 +1,7 @@ @extends('layouts.librenmsv1') @section('javascript') - + @endsection @section('content') diff --git a/resources/views/auth/public-status.blade.php b/resources/views/auth/public-status.blade.php index 1e69579462..fb21670d45 100644 --- a/resources/views/auth/public-status.blade.php +++ b/resources/views/auth/public-status.blade.php @@ -25,7 +25,7 @@ @foreach($devices as $device)