Run the installed panel behind Apache over HTTPS
This commit is contained in:
1 parent
7295f00008
commit
c20c41b2cd
4 files changed
+84
-1
No files matched your search
@@ -593,6 +593,71 @@ PHP-FPM configurations, and makes an HTTP request with the account's primary
|
||||
domain. A passing check confirms PHP execution through the generated socket.
|
||||
The container uses its own filesystem and loopback interface.
|
||||
|
||||
## Run the installed panel behind Apache
|
||||
|
||||
Install the panel with the `server` extra to include Gunicorn. Use the
|
||||
`mariadb` extra as well when the panel database runs on MariaDB.
|
||||
|
||||
```sh
|
||||
python -m pip install '.[server,mariadb]'
|
||||
```
|
||||
|
||||
Set the panel hostname and enable HTTPS proxy mode. Use a persistent random
|
||||
`COULOBRE_SECRET_KEY` for the panel, worker, and scheduler. Create the static
|
||||
directory with write access for the user running `collectstatic` and read
|
||||
access for Apache.
|
||||
|
||||
```sh
|
||||
export DJANGO_SETTINGS_MODULE=coulobre.settings
|
||||
export COULOBRE_ALLOWED_HOSTS=panel.example.net
|
||||
export COULOBRE_HTTPS_PROXY=1
|
||||
export COULOBRE_STATIC_ROOT=/var/www/coulobre-panel-static
|
||||
python -m django check --deploy
|
||||
python -m django migrate
|
||||
python -m django collectstatic --noinput
|
||||
```
|
||||
|
||||
HTTPS proxy mode enables HSTS for the panel hostname. Django reports `W005`
|
||||
and `W021` for the optional subdomain and browser preload settings.
|
||||
|
||||
Run Gunicorn as a dedicated unprivileged user. Give that user ownership of
|
||||
`/run/coulobre-panel` with group `www-data` and mode `0750`. Run Gunicorn with
|
||||
that directory's group so Apache workers can connect to its Unix socket.
|
||||
Restrict socket access to the panel process and Apache workers, including when
|
||||
the panel shares the server with hosted sites.
|
||||
|
||||
```sh
|
||||
gunicorn --bind unix:/run/coulobre-panel/panel.sock --umask 0o007 \
|
||||
--no-control-socket --forwarder-headers '' coulobre.wsgi:application
|
||||
```
|
||||
|
||||
Enable the Apache `headers`, `proxy`, and `proxy_http` modules. Add these
|
||||
directives inside the panel's HTTPS virtual host alongside the TLS certificate
|
||||
configuration. Redirect HTTP to HTTPS in the panel's port 80 virtual host.
|
||||
Apache sets the protocol header itself. Django uses it to recognize HTTPS
|
||||
requests and verify the origin of form submissions. HTTPS proxy mode also
|
||||
marks session and CSRF cookies as secure.
|
||||
[Django HTTPS proxy settings](https://docs.djangoproject.com/en/5.2/ref/settings/#secure-proxy-ssl-header)
|
||||
|
||||
```apache
|
||||
ProxyRequests Off
|
||||
ProxyPreserveHost On
|
||||
RequestHeader unset X-Forwarded-Protocol
|
||||
RequestHeader unset X-Forwarded-Ssl
|
||||
RequestHeader set X-Forwarded-Proto "https"
|
||||
|
||||
ProxyPass /static/ !
|
||||
Alias /static/ /var/www/coulobre-panel-static/
|
||||
<Directory /var/www/coulobre-panel-static/>
|
||||
AllowOverride None
|
||||
Options None
|
||||
Require all granted
|
||||
</Directory>
|
||||
|
||||
ProxyPass / "unix:/run/coulobre-panel/panel.sock|http://localhost/"
|
||||
ProxyPassReverse / http://localhost/
|
||||
```
|
||||
|
||||
## MariaDB
|
||||
|
||||
Create a dedicated MariaDB database and application user. Install the MariaDB or
|
||||
|
||||
Reference in new issue
Block a user