Skip to content

Wallos: Open-source, self-hostable personal subscription tracker. Visualize your recurring expenses, manage your budget, and save money.

1.5 KB
Raw Blame
server {
    listen [::]:80 ipv6only=off;
    server_name your_domain_or_ip; # Change to your domain or IP

    root /var/www/html; # Change to your web root directory

    # Database backups (with logos) can be tens of MB. Without this, a restore
    # upload is rejected with 413 before PHP sees it.
    client_max_body_size 256M;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    # Deny rules must precede the generic \.php$ handler below. nginx evaluates
    # regex locations in order and uses the first match, so these have to come
    # first — otherwise \.php$ matches and executes PHP under .tmp/, logos/, etc.
    location ~ \.db$ {
        deny all;
        return 403;
    }

    location ~* images/uploads/logos/.*\.php$ {
        deny all;
        return 403;
    }

    # Block all direct access to the temp working directory. Nothing there is
    # ever meant to be served (backups, restore staging, etc.). The prefix
    # match outranks the \.php$ regex below, so extracted PHP is unreachable.
    location ^~ /.tmp/ {
        deny all;
        return 403;
    }

    location ~* ^/includes/.*\.php$ {
        deny all;
        return 403;
    }

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass unix:/var/run/php-fpm.sock; # Adjust the path if necessary
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    # Additional configuration if needed
}