Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force root url if set by user #9266

Merged
merged 3 commits into from
Oct 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public function boot()
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) {
Expand Down
2 changes: 1 addition & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
|
*/

'url' => env('APP_URL', 'http://localhost'),
'url' => env('APP_URL'),

/*
|--------------------------------------------------------------------------
Expand Down
13 changes: 13 additions & 0 deletions doc/Support/Environment-Variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,26 @@ 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.

```dotenv
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.
Expand Down
3 changes: 3 additions & 0 deletions doc/Support/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -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']`.

### <a name='my-alerts-aren't-being-delivered-on-time'>My alerts aren't being delivered on time</a>
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.
2 changes: 1 addition & 1 deletion resources/views/auth/2fa.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@extends('layouts.librenmsv1')

@section('javascript')
<script src="js/jquery.qrcode.min.js"></script>
<script src="{{ asset('js/jquery.qrcode.min.js') }}"></script>
@endsection

@section('content')
Expand Down
2 changes: 1 addition & 1 deletion resources/views/auth/public-status.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
@foreach($devices as $device)
<tr>
<td><span class="alert-status {{ $device->status ? 'label-success' : 'label-danger' }}"></span></td>
<td><img src="{{ $device->icon }}" width="32px" height="32px"></td>
<td><img src="{{ asset($device->icon) }}" width="32px" height="32px"></td>
<td class="device-name">{{ $device->displayName() }}</td>
<td>{{ $device->hardware }} {{ $device->features }}</td>
<td>{{ $device->formatUptime(true) }}<br>{{ substr($device->location, 0, 32) }}</td>
Expand Down
100 changes: 50 additions & 50 deletions resources/views/layouts/librenmsv1.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,66 +8,66 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@if(!LibreNMS\Config::get('favicon', false))
<link rel="apple-touch-icon" sizes="180x180" href="images/apple-touch-icon.png">
<link rel="icon" type="image/png" href="images/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="images/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="images/manifest.json">
<link rel="mask-icon" href="images/safari-pinned-tab.svg" color="#5bbad5">
<link rel="shortcut icon" href="images/favicon.ico">
<link rel="apple-touch-icon" sizes="180x180" href="{{ asset('images/apple-touch-icon.png') }}">
<link rel="icon" type="image/png" href="{{ asset('images/favicon-32x32.png') }}" sizes="32x32">
<link rel="icon" type="image/png" href="{{ asset('images/favicon-16x16.png') }}" sizes="16x16">
<link rel="manifest" href="{{ asset('images/manifest.json') }}">
<link rel="mask-icon" href="{{ asset('images/safari-pinned-tab.svg') }}" color="#5bbad5">
<link rel="shortcut icon" href="{{ asset('images/favicon.ico') }}">
<meta name="csrf-token" content="{{ csrf_token() }}">
<meta name="msapplication-config" content="images/browserconfig.xml">
<meta name="theme-color" content="#ffffff">
@else
<link rel="shortcut icon" href="{{ LibreNMS\Config::get('favicon') }}" />
@endif

<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="css/bootstrap-datetimepicker.min.css" rel="stylesheet" type="text/css" />
<link href="css/bootstrap-switch.min.css" rel="stylesheet" type="text/css" />
<link href="css/toastr.min.css" rel="stylesheet" type="text/css" />
<link href="css/jquery-ui.min.css" rel="stylesheet" type="text/css" />
<link href="css/jquery.bootgrid.min.css" rel="stylesheet" type="text/css" />
<link href="css/tagmanager.css" rel="stylesheet" type="text/css" />
<link href="css/mktree.css" rel="stylesheet" type="text/css" />
<link href="css/vis.min.css" rel="stylesheet" type="text/css" />
<link href="css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<link href="css/jquery.gridster.min.css" rel="stylesheet" type="text/css" />
<link href="css/leaflet.css" rel="stylesheet" type="text/css" />
<link href="css/MarkerCluster.css" rel="stylesheet" type="text/css" />
<link href="css/MarkerCluster.Default.css" rel="stylesheet" type="text/css" />
<link href="css/leaflet.awesome-markers.css" rel="stylesheet" type="text/css" />
<link href="css/select2.min.css" rel="stylesheet" type="text/css" />
<link href="css/select2-bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="css/query-builder.default.min.css" rel="stylesheet" type="text/css" />
<link href="{{ LibreNMS\Config::get('stylesheet', 'css/styles.css') }}?ver=20180512" rel="stylesheet" type="text/css" />
<link href="css/{{ LibreNMS\Config::get('site_style', 'light') }}.css?ver=632417642" rel="stylesheet" type="text/css" />
<link href="{{ asset('css/bootstrap.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('css/bootstrap-datetimepicker.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('css/bootstrap-switch.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('css/toastr.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('css/jquery-ui.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('css/jquery.bootgrid.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('css/tagmanager.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('css/mktree.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('css/vis.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('css/font-awesome.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('css/jquery.gridster.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('css/leaflet.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('css/MarkerCluster.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('css/MarkerCluster.Default.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('css/leaflet.awesome-markers.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('css/select2.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('css/select2-bootstrap.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('css/query-builder.default.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset(LibreNMS\Config::get('stylesheet', 'css/styles.css')) }}?ver=20180512" rel="stylesheet" type="text/css" />
<link href="{{ asset('css/' . LibreNMS\Config::get('site_style', 'light') . '.css?ver=632417642') }}" rel="stylesheet" type="text/css" />
@foreach(LibreNMS\Config::get('webui.custom_css', []) as $custom_css)
<link href="{{ $custom_css }}" rel="stylesheet" type="text/css" />
<link href="{{ asset($custom_css) }}" rel="stylesheet" type="text/css" />
@endforeach
@yield('css')

<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/bootstrap-hover-dropdown.min.js"></script>
<script src="js/bootstrap-switch.min.js"></script>
<script src="js/hogan-2.0.0.js"></script>
<script src="js/jquery.cycle2.min.js"></script>
<script src="js/moment.min.js"></script>
<script src="js/bootstrap-datetimepicker.min.js"></script>
<script src="js/typeahead.bundle.min.js"></script>
<script src="js/jquery-ui.min.js"></script>
<script src="js/tagmanager.js"></script>
<script src="js/mktree.js"></script>
<script src="js/jquery.bootgrid.min.js"></script>
<script src="js/handlebars.min.js"></script>
<script src="js/pace.min.js"></script>
<script src="js/qrcode.min.js"></script>
<script src="{{ asset('js/jquery.min.js') }}"></script>
<script src="{{ asset('js/bootstrap.min.js') }}"></script>
<script src="{{ asset('js/bootstrap-hover-dropdown.min.js') }}"></script>
<script src="{{ asset('js/bootstrap-switch.min.js') }}"></script>
<script src="{{ asset('js/hogan-2.0.0.js') }}"></script>
<script src="{{ asset('js/jquery.cycle2.min.js') }}"></script>
<script src="{{ asset('js/moment.min.js') }}"></script>
<script src="{{ asset('js/bootstrap-datetimepicker.min.js') }}"></script>
<script src="{{ asset('js/typeahead.bundle.min.js') }}"></script>
<script src="{{ asset('js/jquery-ui.min.js') }}"></script>
<script src="{{ asset('js/tagmanager.js') }}"></script>
<script src="{{ asset('js/mktree.js') }}"></script>
<script src="{{ asset('js/jquery.bootgrid.min.js') }}"></script>
<script src="{{ asset('js/handlebars.min.js') }}"></script>
<script src="{{ asset('js/pace.min.js') }}"></script>
<script src="{{ asset('js/qrcode.min.js') }}"></script>
@if(LibreNMS\Config::get('enable_lazy_load', true))
<script src="js/jquery.lazyload.min.js"></script>
<script src="js/lazyload.js"></script>
<script src="{{ asset('js/jquery.lazyload.min.js') }}"></script>
<script src="{{ asset('js/lazyload.js') }}"></script>
@endif
<script src="js/select2.min.js"></script>
<script src="js/librenms.js?ver=20180512"></script>
<script src="{{ asset('js/select2.min.js') }}"></script>
<script src="{{ asset('js/librenms.js?ver=20180512') }}"></script>
<script type="text/javascript">

<!-- Begin
Expand All @@ -79,9 +79,9 @@ function popUp(URL)
}
// End -->
</script>
<script type="text/javascript" src="js/overlib_mini.js"></script>
<script type="text/javascript" src="js/toastr.min.js"></script>
<script type="text/javascript" src="js/boot.js"></script>
<script type="text/javascript" src="{{ asset('js/overlib_mini.js') }}"></script>
<script type="text/javascript" src="{{ asset('js/toastr.min.js') }}"></script>
<script type="text/javascript" src="{{ asset('js/boot.js') }}"></script>
@yield('javascript')
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
});

// Debugbar routes need to be here because of catch-all
if (config('app.env') !== 'production' && config('app.debug')) {
if (config('app.env') !== 'production' && config('app.debug') && config('debugbar.enabled') !== false) {
Route::get('/_debugbar/assets/stylesheets', [
'as' => 'debugbar-css',
'uses' => '\Barryvdh\Debugbar\Controllers\AssetController@css'
Expand Down