server {
    index dir2cast.php;
    server_name dir2cast;
    error_log  /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log;
    root /var/www/html;

    # Don't allow downloading of dir2cast.ini, as it may contain sensitive
    # info such as the refresh password. Also, don't allow downloading of
    # dir2cast.php, for security and privacy reasons.
    location ~ /dir2cast\.(ini|php)$ {
        return 404;
    }

    # All directories and sub-folders (that is, URLs ending /) are potential podcast folders.
    # If you only have one podcast, you can change this to "location / {"
    location ~ ^(.*/)$ {
        include fastcgi_params;
        fastcgi_pass php-fpm:9000;

        set $args $args&dir=/var/www/html$1;

        # We load dir2cast from a well known location, so it doesn't have to be in your podcast folder.
        # You can map this in from somewhere outside document root if you like, or build a php-fpm docker
        # image which has it copied in.
        fastcgi_param SCRIPT_FILENAME /dir2cast.php;

        # Security feature. See https://httpoxy.org/
        fastcgi_param HTTP_PROXY "";
    }
}
