server {
    server_name marlons-archive.org www.marlons-archive.org;
    root /mnt/marlons-archive/files;
    charset UTF-8;
    index index.php index.html index.htm;

    access_log /var/log/nginx/marlons-archive.access.log;
    error_log  /var/log/nginx/marlons-archive.error.log;

    location / {
        fancyindex_ignore description.md;
        fancyindex_hide_parent_dir on;
        fancyindex_show_path off;
	fancyindex on;
        fancyindex_exact_size off;
        fancyindex_localtime on;
        fancyindex_name_length 100;
        fancyindex_header /header.html;
	fancyindex_footer /footer.html;
        fancyindex_css_href /style.css;
        }

    location ~ /(favicon.ico|apple-touch-icon.png)$ {
      root /var/www/marlonivo/public/;
    }
 
    location = /magnets.txt {
       alias /var/www/marlons-archive/magnets.txt;
       add_header Content-Type text/plain;
    }

    location = /header.html { root /var/www/marlons-archive; }
    
    location = /footer.html { root /var/www/marlons-archive; } 
    
    location = /style.css   { root /var/www/marlons-archive; }

    location ~ \.php$ {
        try_files $uri =404;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param REDIRECT_STATUS 200;
        fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
    }

    location /transmission/ {
        proxy_pass http://127.0.0.1:9091/transmission/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_pass_header X-Transmission-Session-Id;
    }

    listen [::]:443 ssl; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/marlons-archive.org/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/marlons-archive.org/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


}

server {
    if ($host = www.marlons-archive.org) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = marlons-archive.org) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80;
    listen [::]:80;
    server_name marlons-archive.org www.marlons-archive.org;
    return 404; # managed by Certbot
}
