From 36c659cfe2f44abb12e40490d19262135904068b Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Thu, 7 Dec 2023 18:54:47 +0100 Subject: [PATCH] implemented multiple domain string substitution for mybb --- roles/docker-funkwhale/vars/main.yml | 2 +- roles/docker-mailu/tasks/main.yml | 2 +- roles/docker-mybb/README.md | 19 ++++++------------- roles/docker-mybb/tasks/main.yml | 6 +++--- roles/docker-mybb/tasks/mybb-proxy-domain.yml | 7 +++++++ roles/docker-mybb/vars/main.yml | 1 + roles/docker-pixelfed/vars/main.yml | 2 +- roles/docker-wordpress/tasks/main.yml | 2 +- .../templates/domain.conf.j2 | 7 ++++--- 9 files changed, 25 insertions(+), 23 deletions(-) create mode 100644 roles/docker-mybb/tasks/mybb-proxy-domain.yml diff --git a/roles/docker-funkwhale/vars/main.yml b/roles/docker-funkwhale/vars/main.yml index fe67f9b4..95783741 100644 --- a/roles/docker-funkwhale/vars/main.yml +++ b/roles/docker-funkwhale/vars/main.yml @@ -1,2 +1,2 @@ docker_compose_instance_directory: "{{path_docker_compose_instances}}funkwhale/" -client_max_body_size: "512M" +nginx_docker_reverse_proxy_extra_configuration: "client_max_body_size 512M;" diff --git a/roles/docker-mailu/tasks/main.yml b/roles/docker-mailu/tasks/main.yml index 26fedd3f..f7a710e8 100644 --- a/roles/docker-mailu/tasks/main.yml +++ b/roles/docker-mailu/tasks/main.yml @@ -2,7 +2,7 @@ - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml vars: - client_max_body_size: "31M" + nginx_docker_reverse_proxy_extra_configuration: "client_max_body_size 31M;" - name: "create {{path_docker_compose_instances}}mailu" file: diff --git a/roles/docker-mybb/README.md b/roles/docker-mybb/README.md index 8d2f6bdd..e4ec6fc7 100644 --- a/roles/docker-mybb/README.md +++ b/roles/docker-mybb/README.md @@ -3,21 +3,14 @@ ## Dependencies - nginx-docker-reverse-proxy -## Variables -- `docker_compose_instance_directory`: The directory where Docker Compose files for MyBB are stored. -- `target_mount_conf_d_directory`: Directory for Docker Nginx configuration. -- `default_conf_docker_file`: The default Nginx configuration file for the server. -- `docker_compose_instance_confd_directory`: The Nginx server's configuration directory. - -## Tasks -1. **Domain Certificate Retrieval:** Automates the process of obtaining SSL certificates for the specified domain using Certbot. -2. **Nginx Configuration:** Handles the configuration of Nginx for the MyBB domain. -3. **Directory Creation:** Ensures the creation of necessary directories including parent directories as required. -4. **MyBB and Nginx Configuration:** Manages the configuration for MyBB and Nginx, including setting up the `default.conf` file. -5. **Docker Compose Setup:** Adds and manages the `docker-compose.yml` file necessary for running MyBB with Docker. - ## Usage +### Multi Domain Installation +If you want to access your mybb over multiple domains, keep the following in mind: +- Set Cookie Domain to nothing +- Access mybb for installation via mybb. +- Set the Board Url to mybb. + ### Manual Installation of MyBB Plugins This guide describes the process of manually installing MyBB plugins in your Docker-MyBB environment. This can be useful if you want to quickly test plugins or do not wish to execute the Ansible role. diff --git a/roles/docker-mybb/tasks/main.yml b/roles/docker-mybb/tasks/main.yml index 7b2f348c..924361e1 100644 --- a/roles/docker-mybb/tasks/main.yml +++ b/roles/docker-mybb/tasks/main.yml @@ -1,7 +1,7 @@ --- -- name: "include tasks nginx-docker-proxy-domain.yml" - include_tasks: nginx-docker-proxy-domain.yml - loop: "{{ domains }}" +- name: "include tasks mybb-proxy-domain.yml" + include_tasks: mybb-proxy-domain.yml + loop: "{{ domains + [mybb_main_domain] }}" loop_control: loop_var: domain diff --git a/roles/docker-mybb/tasks/mybb-proxy-domain.yml b/roles/docker-mybb/tasks/mybb-proxy-domain.yml new file mode 100644 index 00000000..547dc771 --- /dev/null +++ b/roles/docker-mybb/tasks/mybb-proxy-domain.yml @@ -0,0 +1,7 @@ +- name: "include task certbot-matomo.yml" + include_tasks: certbot-matomo.yml + +- name: "include task create-domain-conf.yml" + include_tasks: create-domain-conf.yml + vars: + nginx_docker_reverse_proxy_extra_configuration: "sub_filter '{{mybb_main_domain}}' '{{domain}}';" diff --git a/roles/docker-mybb/vars/main.yml b/roles/docker-mybb/vars/main.yml index 02445e66..7a71791c 100644 --- a/roles/docker-mybb/vars/main.yml +++ b/roles/docker-mybb/vars/main.yml @@ -3,3 +3,4 @@ docker_compose_instance_directory: "{{path_docker_compose_instances}}mybb/" docker_compose_instance_confd_directory: "{{docker_compose_instance_directory}}conf.d/" docker_compose_instance_confd_defaultconf_file: "{{docker_compose_instance_confd_directory}}default.conf" target_mount_conf_d_directory: "/etc/nginx/conf.d/" +mybb_main_domain: "mybb.{{top_domain}}" diff --git a/roles/docker-pixelfed/vars/main.yml b/roles/docker-pixelfed/vars/main.yml index 976ab2df..18e0fd57 100644 --- a/roles/docker-pixelfed/vars/main.yml +++ b/roles/docker-pixelfed/vars/main.yml @@ -1,2 +1,2 @@ docker_compose_instance_directory: "{{path_docker_compose_instances}}pixelfed/" -client_max_body_size: "512M" +nginx_docker_reverse_proxy_extra_configuration: "client_max_body_size 512M;" diff --git a/roles/docker-wordpress/tasks/main.yml b/roles/docker-wordpress/tasks/main.yml index 8969a183..f9738e7a 100644 --- a/roles/docker-wordpress/tasks/main.yml +++ b/roles/docker-wordpress/tasks/main.yml @@ -6,7 +6,7 @@ loop_control: loop_var: domain vars: - client_max_body_size: "{{wordpress_max_upload_size}}" + nginx_docker_reverse_proxy_extra_configuration: "client_max_body_size {{wordpress_max_upload_size}};" - name: "create {{docker_compose_instance_directory}}" file: diff --git a/roles/nginx-docker-reverse-proxy/templates/domain.conf.j2 b/roles/nginx-docker-reverse-proxy/templates/domain.conf.j2 index e69f4226..a160264b 100644 --- a/roles/nginx-docker-reverse-proxy/templates/domain.conf.j2 +++ b/roles/nginx-docker-reverse-proxy/templates/domain.conf.j2 @@ -2,13 +2,14 @@ server { server_name {{domain}}; + # Include Matomo Tracking Code {% if nginx_matomo_tracking_active | default(False) %} {% include 'roles/nginx-matomo-tracking/templates/matomo-tracking.conf.j2' %} {% endif %} - - {% if client_max_body_size is defined %} - client_max_body_size {{ client_max_body_size }}; + # Additional Domain Specific Configuration + {% if nginx_docker_reverse_proxy_extra_configuration is defined %} + {{nginx_docker_reverse_proxy_extra_configuration}} {% endif %} {% include 'roles/letsencrypt/templates/ssl_header.j2' %}