From 09c620115d6380bae2c33c98d6ce16ff989c162a Mon Sep 17 00:00:00 2001 From: Ken Dreyer Date: Fri, 14 Aug 2015 12:55:38 -0600 Subject: [PATCH] puddle: add "dev-puddle" virtualhost In DNS, dev-puddle is a CNAME to puddle. Set up Nginx's configuration file to handle this new name and route the requests to a dedicated "dev-puddle" htdocs directory. Update the nginx task to create multiple docroots, and add "dev-puddle" to be the second one. --- roles/puddle/tasks/nginx.yml | 7 +++++-- roles/puddle/templates/nginx.conf | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/roles/puddle/tasks/nginx.yml b/roles/puddle/tasks/nginx.yml index b5d0fe3..0ad6715 100644 --- a/roles/puddle/tasks/nginx.yml +++ b/roles/puddle/tasks/nginx.yml @@ -4,12 +4,15 @@ name: nginx state: present -- name: create nginx docroot +- name: create nginx docroots file: - path: "/var/www/{{ ansible_hostname }}/htdocs" + path: "/var/www/{{ item }}/htdocs" owner: "{{ puddle_user }}" mode: 0755 state: directory + with_items: + - "dev-{{ ansible_hostname }}" + - "{{ ansible_hostname }}" - name: configure nginx template: diff --git a/roles/puddle/templates/nginx.conf b/roles/puddle/templates/nginx.conf index e2f4b08..85ab525 100644 --- a/roles/puddle/templates/nginx.conf +++ b/roles/puddle/templates/nginx.conf @@ -71,4 +71,28 @@ http { text/plain manifest MD5SUM SHA1SUM SHA256SUM; } } + + server { + listen 80; + listen [::]:80; + server_name dev-{{ ansible_fqdn }}; + root /var/www/dev-{{ ansible_hostname }}/htdocs; + + location / { + autoindex on; + autoindex_exact_size off; + } + + # Some of distill's files have no suffix and are simply plaintext. + location ~ (COMPOSE_ID|STATUS)$ { + default_type text/plain; + } + + types { + # Plaintext files from puddle and distill: + text/plain conf log repo txt; + # More from distill: + text/plain manifest MD5SUM SHA1SUM SHA256SUM; + } + } } -- 2.39.5