#####################################
### someone"s ansible provisioner ###
#####################################
# Part of: https://git.somenet.org/root/pub/somesible.git
# 2017-2025 by someone <someone@somenet.org>
#
---
vhost_custom_pre_server: |-

vhost_custom: |-
    # image authentication
    location ~ ^/images/ {
        if (!-f $request_filename){ return 404; }
        rewrite ^/images/(.*)$ /img_auth.php/$1?$args last;
    }

    # hide some paths
    location ^~ /images/deleted/ { return 404; }
    location ^~ /maintenance/ { return 404; }
    location ^~ /cache/ { return 404; }
    location ^~ /logs/ { return 404; }

    # cacheable static files
    location ~ ^/(?!wiki\/).*\.(css|js|gif|jpg|jpeg|png|svg|wasm|ttf|woff|woff2|ico)$ {
        try_files $uri =404;
        add_header Cache-Control "public";
        expires 7d;
    }

    # nice urls
    location ~ ^/wiki/ { rewrite ^/wiki/(.*)$ /index.php?title=$1&$args last; }

    ## keep for legacy-reasons
    location = /wiki { rewrite ^ /index.php permanent; }
    # old. maybe delete in 2023-07?
    location ^~ /wiki/index.php/ { rewrite ^/wiki/index.php/(.*)$ /wiki/$1 permanent; }
    location ^~ /index.php/ { rewrite ^/index.php/(.*)$ /wiki/$1 permanent; }
