Skip to content
Closed
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
5 changes: 5 additions & 0 deletions app/eventyay/config/next_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ class BaseSettings(_BaseSettings):
linkedin_client_secret: str = ''
# Ask to provide comments when making changes in the admin interface.
admin_audit_comments_asked: bool = False
# Video Vue app: Allow Nginx to serve static assets (opt-in, default: False)
nginx_serve_static: bool = False

@classmethod
def settings_customise_sources(
Expand Down Expand Up @@ -242,6 +244,9 @@ def increase_redis_db(url: str, increment: int) -> str:
SECRET_KEY = conf.secret_key
DATABASE_REPLICA = 'default'

# Video Vue app: Allow Nginx to serve static assets (opt-in, default: False)
VIDEO_STATIC_NGINX_SERVE = conf.nginx_serve_static

DATA_DIR = BASE_DIR / 'data'
LOG_DIR = DATA_DIR / 'logs'
MEDIA_ROOT = DATA_DIR / 'media'
Expand Down
6 changes: 6 additions & 0 deletions app/eventyay/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,12 @@ def instance_name(request):
]

STATIC_ROOT = BASE_DIR / 'static.dist'

# Video Vue app: Allow Nginx to serve static assets (opt-in, default: False)
VIDEO_STATIC_NGINX_SERVE = config.getboolean(
'video', 'nginx_serve_static', fallback=False
)

STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
Expand Down
8 changes: 8 additions & 0 deletions app/eventyay/multidomain/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
WEBAPP_DIST_DIR = cast(Path, settings.STATIC_ROOT) / 'webapp'
logger = logging.getLogger(__name__)

# File extensions expected to be served by Nginx when VIDEO_STATIC_NGINX_SERVE is enabled
VIDEO_STATIC_NGINX_EXTENSIONS = {'.js', '.css', '.map'}


def safe_reverse(name: str, **kw) -> str:
try:
Expand Down Expand Up @@ -129,6 +132,11 @@ def default(self, obj):

class VideoAssetView(View):
def get(self, request, path='', *args, **kwargs):
# When VIDEO_STATIC_NGINX_SERVE is enabled, skip serving static assets
if settings.VIDEO_STATIC_NGINX_SERVE and path:
_, ext = os.path.splitext(path.lower())
if ext in VIDEO_STATIC_NGINX_EXTENSIONS:
raise Http404()
# Accept empty path -> index handling done by SPA view
candidate_paths = (
[
Expand Down
21 changes: 21 additions & 0 deletions deployment/nginx/enext-direct
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,27 @@ server {
access_log off;
expires 30d;
}

# Video Vue app static assets (optional Nginx serving)
# Uncomment this block to serve Video Vue static assets directly from Nginx.
# This requires setting nginx_serve_static = true in the [video] section of eventyay.cfg
# or nginx_serve_static: true in eventyay.*.toml configuration files.
# When enabled, Django will return 404 for these assets, allowing Nginx to serve them.
#
# location ~ ^/[^/]+/[^/]+/video/assets/ {
# alias <PATH_TO>/data/compiled-frontend/;
# access_log off;
# expires 30d;
# add_header Cache-Control "public, immutable";
# }
#
# location ~ ^/[^/]+/[^/]+/video/.*\.(js|css|map)$ {
# alias <PATH_TO>/data/compiled-frontend/;
# access_log off;
# expires 30d;
# add_header Cache-Control "public, immutable";
# }

listen 80;
}