upstream lutris_server {
    server unix:%ROOT%/run/gunicorn.sock fail_timeout=0;
}

server {
    listen 80;
    server_name www.lutris.net;
    return 301 $scheme://lutris.net$request_uri;
}

server {
    listen 80;
    server_name lutris.net;

    client_max_body_size 4G;

    add_header X-Frame-Options SAMEORIGIN;
    add_header X-XSS-Protection 1;
    add_header Content-Security-Policy "frame-ancestors 'self'";
    add_header X-Content-Type-Options "nosniff" always;

    access_log %ROOT%/logs/nginx-access.log;
    error_log %ROOT%/logs/nginx-error.log;

    location /static/ {
        alias %ROOT%/lutris.net/static/;
    }

    location /media/ {
        alias %ROOT%/lutris.net/media/;
    }

    location /files {
        alias /srv/files/;
        autoindex on;
    }

    location /releases {
        alias /srv/releases/;
        autoindex on;
    }

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        if (!-f $request_filename) {
            proxy_pass http://lutris_server;
            break;
        }
    }

    error_page 500 502 503 504 /500.html;
    location = /500.html {
        root %ROOT%/lutris.net/templates/;
    }
}
