mirror of
https://github.com/eduardogsilva/wireguard_webadmin.git
synced 2026-01-01 06:16:16 +00:00
Enable static file caching with WhiteNoise and nginx. Switch to Gunicorn for deployment
This commit is contained in:
2
init.sh
2
init.sh
@@ -16,4 +16,4 @@ fi
|
||||
# Django startup
|
||||
python manage.py migrate --noinput
|
||||
python manage.py collectstatic --noinput
|
||||
exec python manage.py runserver 0.0.0.0:8000
|
||||
exec gunicorn wireguard_webadmin.wsgi:application --bind 0.0.0.0:8000 --workers 2 --threads 2 --timeout 60 --log-level info --capture-output --access-logfile - --error-logfile -
|
||||
@@ -14,6 +14,8 @@ server {
|
||||
|
||||
location /static/ {
|
||||
alias /static/;
|
||||
expires 1h;
|
||||
add_header Cache-Control "public";
|
||||
}
|
||||
|
||||
location / {
|
||||
|
||||
@@ -51,6 +51,7 @@ INSTALLED_APPS = [
|
||||
|
||||
MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'whitenoise.middleware.WhiteNoiseMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.locale.LocaleMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
@@ -59,6 +60,15 @@ MIDDLEWARE = [
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
]
|
||||
|
||||
STORAGES = {
|
||||
"staticfiles": {
|
||||
"BACKEND": "whitenoise.storage.CompressedStaticFilesStorage",
|
||||
},
|
||||
}
|
||||
|
||||
WHITENOISE_MAX_AGE = 3600
|
||||
|
||||
CRISPY_ALLOWED_TEMPLATE_PACKS = "bootstrap4"
|
||||
CRISPY_TEMPLATE_PACK = "bootstrap4"
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ Including another URLconf
|
||||
1. Import the include() function: from django.urls import include, path
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.contrib import admin
|
||||
from django.urls import path
|
||||
|
||||
from accounts.views import view_create_first_user, view_login, view_logout
|
||||
@@ -39,7 +38,7 @@ from wireguard_peer.views import view_manage_ip_address, view_wireguard_peer_lis
|
||||
from wireguard_tools.views import download_config_or_qrcode, export_wireguard_configs, restart_wireguard_interfaces
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
# path('admin/', admin.site.urls),
|
||||
path('', view_apply_db_patches, name='apply_db_patches'),
|
||||
path('status/', view_wireguard_status, name='wireguard_status'),
|
||||
path('dns/', view_static_host_list, name='static_host_list'),
|
||||
|
||||
Reference in New Issue
Block a user