Skip to content

Commit

Permalink
fix(app): add configuration and docs for ssl proxies
Browse files Browse the repository at this point in the history
docs: add documentation for trusted proxies
  • Loading branch information
m-thalmann committed Aug 11, 2024
1 parent 86d5c94 commit 437c271
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ APP_DEBUG=true
APP_URL=http://localhost
APP_DEFAULT_TIMEZONE=UTC

# APP_FORCE_HTTPS=true
# APP_TRUSTED_PROXIES=localhost

# APP_REGISTRATION_ENABLED=true
# APP_EMAIL_VERIFICATION_ENABLED=true
Expand Down
4 changes: 4 additions & 0 deletions app/Http/Middleware/TrustProxies.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ class TrustProxies extends Middleware {
Request::HEADER_X_FORWARDED_PORT |
Request::HEADER_X_FORWARDED_PROTO |
Request::HEADER_X_FORWARDED_AWS_ELB;

public function __construct() {
$this->proxies = [...config('app.trusted_proxies')];
}
}
5 changes: 4 additions & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@

'asset_url' => env('ASSET_URL'),

'force_https' => env('APP_FORCE_HTTPS', false),
'trusted_proxies' => explode(
',',
env('APP_TRUSTED_PROXIES', 'localhost,127.0.0.1,::1')
),

/*
|--------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion docker/.env.docker
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ APP_DEBUG=false
APP_URL=http://localhost
APP_DEFAULT_TIMEZONE=UTC

# APP_FORCE_HTTPS=true
# APP_TRUSTED_PROXIES=localhost

APP_REGISTRATION_ENABLED=false
APP_EMAIL_VERIFICATION_ENABLED=true
Expand Down
16 changes: 8 additions & 8 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ php artisan queue:restart

## General

| Key | Type | Description | :exclamation: |
| ---------------------- | -------- | -------------------------------------------------------------------------- | :-----------: |
| `APP_NAME` | `string` | The name of the application (used in the title e.g.) | |
| `APP_ENV` | `string` | The environment of the application (e.g. `local`, `production`) | |
| `APP_DEBUG` | `bool` | Whether the application is in debug mode | |
| `APP_URL` | `string` | The URL of the application where it is deployed (used for static links) | :exclamation: |
| `APP_DEFAULT_TIMEZONE` | `string` | The default timezone of the application (e.g. `UTC`) | |
| `APP_FORCE_HTTPS` | `bool` | Whether to force using HTTPS for assets and absolute routes within the app | |
| Key | Type | Description | :exclamation: |
| ---------------------- | -------- | ----------------------------------------------------------------------- | :-----------: |
| `APP_NAME` | `string` | The name of the application (used in the title e.g.) | |
| `APP_ENV` | `string` | The environment of the application (e.g. `local`, `production`) | |
| `APP_DEBUG` | `bool` | Whether the application is in debug mode | |
| `APP_URL` | `string` | The URL of the application where it is deployed (used for static links) | :exclamation: |
| `APP_DEFAULT_TIMEZONE` | `string` | The default timezone of the application (e.g. `UTC`) | |
| `APP_TRUSTED_PROXIES` | `string` | The proxies that should be trusted by the application (comma-separated) | |

## Security

Expand Down
7 changes: 6 additions & 1 deletion docs/installation/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,16 @@ You can use a reverse proxy in front of the SecureDAV application to handle SSL
AllowEncodedSlashes NoDecode
ProxyPass / http://localhost:8080/ nocanon
ProxyPassReverse / http://localhost:8080/
RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
</VirtualHost>
```

::: tip IMPORTANT
When using a proxy with SSL in front of the SecureDAV application, you have to adjust the `APP_FORCE_HTTPS` environment variable in the `.env` file to `true`
When using a proxy with SSL in front of the SecureDAV application, make sure to set the `APP_TRUSTED_PROXIES` environment variable in the `.env` file accordingly (comma separated)!
It must include the host or ip address of the proxied server (see `ProxyPass` and `ProxyPassReverse`)!

Example for the virtual host configuration above: `APP_TRUSTED_PROXIES=localhost`
:::

## First run
Expand Down

0 comments on commit 437c271

Please sign in to comment.