Kaynağa Gözat

Make possible to define custom mime types in nginx config

Emmanuel Bouthenot 8 yıl önce
ebeveyn
işleme
88b1551539

+ 11 - 0
roles/webserver/tasks/nginx.yml

@@ -16,6 +16,17 @@
     - 'Restart nginx'
   when: with_nginx
 
+- name: 'Install custom mime types for nginx'
+  template:
+    src: 'nginx/mime.types.custom.j2'
+    dest: '/etc/nginx/mime.types.custom'
+    owner: 'root'
+    group: 'root'
+    mode: '0644'
+  notify:
+    - 'Restart nginx'
+  when: with_nginx
+
 - name: 'Install nginx configuration'
   template:
     src: 'nginx/nginx.conf.j2'

+ 10 - 0
roles/webserver/templates/nginx/mime.types.custom.j2

@@ -0,0 +1,10 @@
+{% if ansible_prolog -%}
+{% from 'templates/ansible/prolog.j2' import prolog with context %}
+{{ prolog() }}
+{% endif -%}
+
+types {
+    application/font-woff2              woff2;
+    application/x-font-truetype         ttf;
+    application/x-font-opentype         otf;
+}

+ 1 - 0
roles/webserver/templates/nginx/nginx.conf.j2

@@ -73,6 +73,7 @@ http {
 
     ### Define the MIME types for files ###
     include       /etc/nginx/mime.types;
+    include       /etc/nginx/mime.types.custom;
     default_type  application/octet-stream;
 
     # Format to use in log files