From 091e10560847e793ce14a36a39a40554eea92144 Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Mon, 2 Sep 2024 03:38:25 +0100 Subject: Treat NGINX responses as UTF-8 Some sites that had non-ASCII characters rendered weirdly because our NGINX configuration was not returning a default charset and so rendering was being left up to browser/standards defaults. This change adds a new config file to /etc/nginx/conf.d/ which forces responses to be interpreted as/transformed to UTF-8. --- ansible/roles/nginx/tasks/main.yml | 17 +++++++++++++++++ .../roles/nginx/templates/nginx-conf.d/charset.conf.j2 | 2 ++ 2 files changed, 19 insertions(+) create mode 100644 ansible/roles/nginx/templates/nginx-conf.d/charset.conf.j2 (limited to 'ansible') diff --git a/ansible/roles/nginx/tasks/main.yml b/ansible/roles/nginx/tasks/main.yml index 37d2793..e6060f1 100644 --- a/ansible/roles/nginx/tasks/main.yml +++ b/ansible/roles/nginx/tasks/main.yml @@ -25,6 +25,23 @@ file: path: /etc/nginx/sites-enabled/default state: absent + tags: + - role::nginx + +- name: Copy conf.d entries + template: + src: "{{ item }}" + dest: "/etc/nginx/conf.d/{{ item | basename | splitext | first }}" + mode: "0444" + owner: root + group: root + with_fileglob: "../templates/nginx-conf.d/*" + loop_control: + label: "{{ item | basename | splitext | first }}" + tags: + - role::nginx + notify: + - Reload the nginx service - name: Copy host-specific configs copy: diff --git a/ansible/roles/nginx/templates/nginx-conf.d/charset.conf.j2 b/ansible/roles/nginx/templates/nginx-conf.d/charset.conf.j2 new file mode 100644 index 0000000..d0db21e --- /dev/null +++ b/ansible/roles/nginx/templates/nginx-conf.d/charset.conf.j2 @@ -0,0 +1,2 @@ +# {{ ansible_managed }} +charset utf-8; -- cgit v1.2.3