server {
    listen 80 default_server;

    root /app;
    index index.php;

    # Make site accessible from http://localhost/
    server_name _;

    location / {
        try_files $uri $uri/ =404;
    }

    location /api {
        rewrite ^/api/?$ /index.php?page=newznabapi last;
    }

    error_page 404 /404.html;

    # pass the PHP scripts to FastCGI server listening on socket
    #
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_buffers 32 4k;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
        fastcgi_param HTTPS $fastcgi_https;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
        expires 5d;
    }

    # deny access to . files, for security
    #
    location ~ /\. {
        log_not_found off;
        deny all;
    }
}
