Commit aee302c3 authored by Lukáš Gorazd Hrodek's avatar Lukáš Gorazd Hrodek
Browse files

docker: add additional nginx configuration templates

- nginx-archive-viewer.conf: generic archive viewer config
- nginx-spa-archive.conf: archive-specific SPA routing
- nginx-spa-subpath.conf: reusable subpath SPA template
- Support flexible deployment patterns across festival versions
parent 7e79d62b
Loading
Loading
Loading
Loading
+52 −0
Original line number Diff line number Diff line
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;

events {
    worker_connections 1024;
}

http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    log_format main '$remote_addr - $remote_user [$time_local] "$request" '
                    '$status $body_bytes_sent "$http_referer" '
                    '"$http_user_agent"';

    access_log /var/log/nginx/access.log main;

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;

    gzip on;
    gzip_vary on;
    gzip_types text/plain text/css text/xml text/javascript application/json application/javascript application/xml;

    server {
        listen 80;
        server_name _;
        root /usr/share/nginx/html;
        index index.html;

        # Security headers
        add_header X-Frame-Options "SAMEORIGIN" always;
        add_header X-Content-Type-Options "nosniff" always;

        # SPA fallback - všechny requesty jdou na index.html
        location / {
            try_files $uri $uri/ /index.html;
        }

        # Static assets with caching
        location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|mp4|webm|ogg)$ {
            expires 1y;
            add_header Cache-Control "public, immutable";
            try_files $uri =404;
        }
    }
}
+69 −0
Original line number Diff line number Diff line
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;

events {
    worker_connections 1024;
}

http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    log_format main '$remote_addr - $remote_user [$time_local] "$request" '
                    '$status $body_bytes_sent "$http_referer" '
                    '"$http_user_agent"';

    access_log /var/log/nginx/access.log main;

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    client_max_body_size 500M;

    gzip on;
    gzip_vary on;
    gzip_types text/plain text/css text/xml text/javascript application/json application/javascript application/xml;

    server {
        listen 80;
        server_name _;
        
        # Root path where files are actually stored
        root /usr/share/nginx/html;
        index index.html;

        # Security headers
        add_header X-Frame-Options "SAMEORIGIN" always;
        add_header X-Content-Type-Options "nosniff" always;

        # Log all requests for debugging
        access_log /var/log/nginx/access.log main;
        error_log /var/log/nginx/error.log debug;

        # Serve everything - SPA will handle routing
        # For any path, try to find the file directly, or serve index.html
        location / {
            # First try exact file, then directory, finally index.html for SPA routing
            try_files $uri $uri/ /index.html;
        }

        # Static assets with caching - higher priority than location /
        location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|mp4|webm|ogg|zip|tar|gz|rar|webmanifest|json|map)$ {
            expires 30d;
            add_header Cache-Control "public, immutable";
            # Try to find the file, return 404 if not found
            try_files $uri =404;
        }

        # Deny access to hidden files
        location ~ /\. {
            deny all;
            access_log off;
            log_not_found off;
        }
    }
}
+93 −0
Original line number Diff line number Diff line
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;

events {
    worker_connections 1024;
}

http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    log_format main '$remote_addr - $remote_user [$time_local] "$request" '
                    '$status $body_bytes_sent "$http_referer" '
                    '"$http_user_agent"';

    access_log /var/log/nginx/access.log main;

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    client_max_body_size 500M;

    gzip on;
    gzip_vary on;
    gzip_types text/plain text/css text/xml text/javascript application/json application/javascript application/xml;

    server {
        listen 80;
        server_name localhost;
        root /usr/share/nginx/html;
        index index.html;

        # Přepsání cest v HTML - přidá /archive/XX/ prefix před absolute paths
        sub_filter_once off;
        sub_filter_types text/html;
        sub_filter '="/_nuxt/' '="/archive/$ARCHIVE_NUM/_nuxt/';
        sub_filter '="/static/' '="/archive/$ARCHIVE_NUM/static/';
        sub_filter '="/fonts/' '="/archive/$ARCHIVE_NUM/fonts/';
        sub_filter '="/page-data/' '="/archive/$ARCHIVE_NUM/page-data/';
        sub_filter '="/images/' '="/archive/$ARCHIVE_NUM/images/';
        sub_filter '="/favicons/' '="/archive/$ARCHIVE_NUM/favicons/';
        sub_filter 'src="/' 'src="/archive/$ARCHIVE_NUM/';
        sub_filter 'href="/' 'href="/archive/$ARCHIVE_NUM/';

        # Statické assety - servovat přímo
        location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|mp4|webm|ogg|zip|tar|gz|rar|webmanifest|json|map|webp)$ {
            try_files $uri =404;
            expires 1y;
            add_header Cache-Control "public, immutable";
        }

        # Nuxt assety
        location /_nuxt/ {
            try_files $uri =404;
            expires 1y;
            add_header Cache-Control "public, immutable";
        }

        # Gatsby/statické assety
        location /static/ {
            try_files $uri =404;
            expires 1y;
            add_header Cache-Control "public, immutable";
        }

        location /fonts/ {
            try_files $uri =404;
            expires 1y;
            add_header Cache-Control "public, immutable";
        }

        location /images/ {
            try_files $uri =404;
            expires 1y;
            add_header Cache-Control "public, immutable";
        }

        location /page-data/ {
            try_files $uri =404;
            expires 5m;
            add_header Cache-Control "public";
        }

        # SPA routing - fallback na index.html
        location / {
            try_files $uri $uri/ /index.html;
        }
    }
}