# nginx configuration for intrusive.games
server {
    root /var/www/intrusive;
    index index.html index.htm;

    server_name intrusive.games www.intrusive.games;

    # Should have been added by certbot but wasnt?
    listen 443 ssl;
    ssl_certificate /etc/letsencrypt/live/intrusive.games/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/intrusive.games/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;


    # Add 1 day expires header for static assets
    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
        expires 1d;
    }

    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to redirecting to index.html
        try_files $uri $uri/ @root;
    }

    # If nginx can't find a file, fallback to the homepage.
    location @root {
        rewrite .* / redirect;
    }

}

server {
    if ($host = intrusive.games) {
        return 301 https://$host$request_uri;
    }

    server_name intrusive.games www.intrusive.games;
    listen 80;
    return 404;
}

server {
   server_name discord.intrusive.games;
   listen 80;
   return 301 https://discord.gg/9ArMrDDUgA;
}
