From 708a128b3c630b208d98a8420724be6c1cef5057 Mon Sep 17 00:00:00 2001 From: Someone Date: Fri, 4 Oct 2024 13:42:46 +0200 Subject: [PATCH] [roles/service/mediawiki-no-install] configure a nginx vhost to serve a mediawiki. no setup or updating is done --- .../mediawiki-no-install/defaults/main.yml | 10 +++++ .../mediawiki-no-install/tasks/main.yml | 32 ++++++++++++++++ .../vars/default/vars_nginx_vhost_custom.yml | 37 +++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 roles/service/mediawiki-no-install/defaults/main.yml create mode 100644 roles/service/mediawiki-no-install/tasks/main.yml create mode 100644 roles/service/mediawiki-no-install/vars/default/vars_nginx_vhost_custom.yml diff --git a/roles/service/mediawiki-no-install/defaults/main.yml b/roles/service/mediawiki-no-install/defaults/main.yml new file mode 100644 index 0000000..bef8d21 --- /dev/null +++ b/roles/service/mediawiki-no-install/defaults/main.yml @@ -0,0 +1,10 @@ +##################################### +### someone's ansible provisioner ### +##################################### +# Part of: https://git.somenet.org/root/pub/somesible.git +# 2017-2024 by someone +# +# If not overridden in inventory or as a parameter, this is the value that will be used +# +--- +mediawiki_domain: "mediawiki.localhost" diff --git a/roles/service/mediawiki-no-install/tasks/main.yml b/roles/service/mediawiki-no-install/tasks/main.yml new file mode 100644 index 0000000..01b634e --- /dev/null +++ b/roles/service/mediawiki-no-install/tasks/main.yml @@ -0,0 +1,32 @@ +##################################### +### someone"s ansible provisioner ### +##################################### +# Part of: https://git.somenet.org/root/pub/somesible.git +# 2017-2024 by someone +# +--- +- name: include vars_nginx_vhost_custom + include_vars: + file: "{{item}}" + name: vars_nginx_vhost_custom + with_first_found: + - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/{{mediawiki_domain}}-vars_nginx_vhost_custom.yml" + - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/{{mediawiki_domain}}-vars_nginx_vhost_custom.yml" + - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/{{mediawiki_domain}}-vars_nginx_vhost_custom.yml" + - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/vars_nginx_vhost_custom.yml" + - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/vars_nginx_vhost_custom.yml" + - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/vars_nginx_vhost_custom.yml" + - "default/vars_nginx_vhost_custom.yml" + + +- name: configure vhost + include_role: + name: server/nginx/vhost-unified + vars: + vhost_type: "php" + vhost_name: "{{mediawiki_domain}}" + vhost_php_custom: ["bzip2", "php-apcu", "php8.2-pgsql", "php8.2-curl", "php8.2-gd", "php8.2-intl", "php-imagick", "php8.2-mbstring", "php8.2-mysql", "php8.2-xml", "php8.2-zip"] + vhost_fix_perms: False + vhost_custom: + vhost_custom_pre_server: "{{vars_nginx_vhost_custom.vhost_custom_pre_server}}" + vhost_custom: "{{vars_nginx_vhost_custom.vhost_custom}}" diff --git a/roles/service/mediawiki-no-install/vars/default/vars_nginx_vhost_custom.yml b/roles/service/mediawiki-no-install/vars/default/vars_nginx_vhost_custom.yml new file mode 100644 index 0000000..de3fe0c --- /dev/null +++ b/roles/service/mediawiki-no-install/vars/default/vars_nginx_vhost_custom.yml @@ -0,0 +1,37 @@ +##################################### +### someone"s ansible provisioner ### +##################################### +# Part of: https://git.somenet.org/root/pub/somesible.git +# 2017-2024 by someone +# +--- +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; } -- 2.43.0