initial version
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
"""
|
||||
ASGI config for creativeschool project.
|
||||
|
||||
It exposes the ASGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.asgi import get_asgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'creativeschool.settings')
|
||||
|
||||
application = get_asgi_application()
|
||||
@@ -0,0 +1,82 @@
|
||||
user nginx;
|
||||
worker_processes auto;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
|
||||
# 🔥 Sécurité basique
|
||||
server_tokens off;
|
||||
|
||||
# 🔥 Logs (Coolify les capte automatiquement)
|
||||
access_log /var/log/nginx/access.log;
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
|
||||
# ===============================
|
||||
# 🔁 HTTP → HTTPS (obligatoire)
|
||||
# ===============================
|
||||
server {
|
||||
listen 80;
|
||||
server_name example.com www.example.com;
|
||||
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
# ===============================
|
||||
# 🔐 HTTPS – Django production
|
||||
# ===============================
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
server_name example.com www.example.com;
|
||||
|
||||
# 🔥 Certificats (gérés par Coolify / Let's Encrypt)
|
||||
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
|
||||
|
||||
# 🔥 Sécurité SSL minimale
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_prefer_server_ciphers on;
|
||||
|
||||
# ===============================
|
||||
# 📦 Fichiers statiques
|
||||
# ===============================
|
||||
location /static/ {
|
||||
alias /static/;
|
||||
expires 30d;
|
||||
access_log off;
|
||||
}
|
||||
|
||||
# ===============================
|
||||
# 🖼️ Médias uploadés
|
||||
# ===============================
|
||||
location /media/ {
|
||||
alias /media/;
|
||||
expires 30d;
|
||||
access_log off;
|
||||
}
|
||||
|
||||
# ===============================
|
||||
# 🧠 Django via Gunicorn
|
||||
# ===============================
|
||||
location / {
|
||||
proxy_pass http://web:8000;
|
||||
|
||||
# 🔥 Headers indispensables pour Django
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
|
||||
proxy_redirect off;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
import os
|
||||
import dj_database_url
|
||||
|
||||
from pathlib import Path
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
|
||||
|
||||
|
||||
|
||||
SECRET_KEY = os.getenv("DJANGO_SECRET_KEY")
|
||||
|
||||
|
||||
DEBUG = os.getenv("DJANGO_DEBUG") == "False"
|
||||
ALLOWED_HOSTS = os.getenv("DJANGO_ALLOWED_HOSTS", "").split(",")
|
||||
|
||||
|
||||
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'jazzmin',
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
"django.contrib.sites",
|
||||
'main',
|
||||
'authentication',
|
||||
'blog',
|
||||
'cart',
|
||||
'dashboard',
|
||||
'allauth',
|
||||
'allauth.account',
|
||||
"allauth.socialaccount",
|
||||
'phonenumber_field',
|
||||
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
"whitenoise.middleware.WhiteNoiseMiddleware",
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
'allauth.account.middleware.AccountMiddleware',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'creativeschool.urls'
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [BASE_DIR.joinpath('templates')],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
'django.template.context_processors.debug',
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
'main.context_processors.categories',
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
AUTHENTICATION_BACKENDS = [
|
||||
|
||||
'django.contrib.auth.backends.ModelBackend',
|
||||
'allauth.account.auth_backends.AuthenticationBackend',
|
||||
]
|
||||
|
||||
WSGI_APPLICATION = 'creativeschool.wsgi.application'
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
"default": dj_database_url.parse(
|
||||
os.environ["DATABASE_URL"],
|
||||
conn_max_age=600,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
|
||||
|
||||
AUTH_PASSWORD_VALIDATORS = [
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
||||
},
|
||||
]
|
||||
|
||||
SITE_ID = 1
|
||||
|
||||
LOGIN_REDIRECT_URL = 'main:home'
|
||||
ACCOUNT_AUTHENTICATION_METHOD = 'email'
|
||||
ACCOUNT_EMAIL_REQUIRED = True
|
||||
ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
|
||||
ACCOUNT_USERNAME_REQUIRED = False
|
||||
ACCOUNT_EMAIL_UNIQUE = True
|
||||
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
|
||||
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/3.0/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
TIME_ZONE = "Africa/Algiers"
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
AUTH_USER_MODEL = 'authentication.User'
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/3.0/howto/static-files/
|
||||
|
||||
STATIC_URL = "/static/"
|
||||
|
||||
STATIC_ROOT = BASE_DIR / "staticfiles"
|
||||
|
||||
STATICFILES_STORAGE = (
|
||||
"whitenoise.storage.CompressedManifestStaticFilesStorage"
|
||||
)
|
||||
MEDIA_URL = "/media/"
|
||||
|
||||
MEDIA_ROOT = "/app/media"
|
||||
# =========================================
|
||||
# 📧 Email (via .env)
|
||||
# =========================================
|
||||
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
|
||||
EMAIL_HOST = os.getenv("EMAIL_HOST")
|
||||
EMAIL_PORT = int(os.getenv("EMAIL_PORT", 587))
|
||||
EMAIL_USE_TLS = os.getenv("EMAIL_USE_TLS") == "True"
|
||||
EMAIL_HOST_USER = os.getenv("EMAIL_HOST_USER")
|
||||
EMAIL_HOST_PASSWORD = os.getenv("EMAIL_HOST_PASSWORD")
|
||||
|
||||
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
|
||||
|
||||
# =========================================
|
||||
# HTTPS / Nginx / Coolify
|
||||
# =========================================
|
||||
|
||||
#SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
|
||||
|
||||
#SESSION_COOKIE_SECURE = not DEBUG
|
||||
#CSRF_COOKIE_SECURE = not DEBUG
|
||||
|
||||
#CSRF_TRUSTED_ORIGINS = [
|
||||
# f"https://{host}" for host in ALLOWED_HOSTS if host
|
||||
#]
|
||||
|
||||
# Optionnel mais recommandé
|
||||
#SECURE_HSTS_SECONDS = 31536000 if not DEBUG else 0
|
||||
#SECURE_HSTS_INCLUDE_SUBDOMAINS = not DEBUG
|
||||
#SECURE_HSTS_PRELOAD = not DEBUG
|
||||
CSRF_TRUSTED_ORIGINS = os.getenv(
|
||||
"CSRF_TRUSTED_ORIGINS",
|
||||
""
|
||||
).split(",")
|
||||
|
||||
SECURE_PROXY_SSL_HEADER = (
|
||||
("HTTP_X_FORWARDED_PROTO", "https")
|
||||
)
|
||||
|
||||
USE_X_FORWARDED_HOST = True
|
||||
|
||||
SESSION_COOKIE_SECURE = not DEBUG
|
||||
|
||||
CSRF_COOKIE_SECURE = not DEBUG
|
||||
|
||||
SECURE_SSL_REDIRECT = not DEBUG
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
from django.contrib import admin
|
||||
from django.urls import path, include
|
||||
from django.conf.urls.static import static
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('', include('main.urls')),
|
||||
path('cart/', include('cart.urls')),
|
||||
path('blog/', include('blog.urls')),
|
||||
path('accounts/', include('allauth.urls')),
|
||||
]
|
||||
|
||||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|
||||
@@ -0,0 +1,16 @@
|
||||
"""
|
||||
WSGI config for creativeschool project.
|
||||
|
||||
It exposes the WSGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'creativeschool.settings')
|
||||
|
||||
application = get_wsgi_application()
|
||||
Reference in New Issue
Block a user