server {
    listen 80 default_server;

    root /usr/share/nginx/html;
    index index.html;

    location / {
        try_files $uri $uri/ /index.html;
    }

    # Docker reverse proxy IP passthrough
    set_real_ip_from 172.16.0.0/12;
    real_ip_header X-Real-IP;

    # Force browsers to check for updated data
    location /data/ {
        add_header Cache-Control no-cache;
        add_header Access-Control-Allow-Origin *;
        autoindex on;
    }

    location /assets/splatnet/ {
        autoindex on;
    }

    location /status-screenshots/ {
        add_header Cache-Control no-cache;
        add_header Access-Control-Allow-Origin *;
        autoindex on;
    }

    # Gear redirect
    location ~ /nso/g/(.*) {
        return 302 https://s.nintendo.com/av5ja-lp1/znca/game/4834290508791808?p=/gesotown/$1;
    }

    # Festival redirect
    location ~ /nso/f/(.*) {
        return 302 https://s.nintendo.com/av5ja-lp1/znca/game/4834290508791808?p=/fest_record/$1;
    }

    # Webfinger
    location ~ /.well-known/(host-meta|webfinger|nodeinfo) {
       return 302 https://fedi.splatoon3.ink$request_uri;
    }

    # Fediverse
    location = /@splatoon3ink {
       return 302 https://fedi.splatoon3.ink/splatoon3ink;
    }
}
