From f8f20478727c2e82cf37a8be363f4d06db6e9a37 Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Fri, 12 Dec 2014 20:04:37 +0000 Subject: [PATCH] haproxy RewriteRule. --- playbooks/groups/proxies-haproxy.yml | 18 ++++++++++++++++++ playbooks/groups/proxies.yml | 1 + roles/haproxy/rewrite/tasks/main.yml | 6 ++++++ roles/haproxy/rewrite/templates/rewrite.conf | 2 ++ 4 files changed, 27 insertions(+) create mode 100644 playbooks/groups/proxies-haproxy.yml create mode 100644 roles/haproxy/rewrite/tasks/main.yml create mode 100644 roles/haproxy/rewrite/templates/rewrite.conf diff --git a/playbooks/groups/proxies-haproxy.yml b/playbooks/groups/proxies-haproxy.yml new file mode 100644 index 0000000000..f64bccc51c --- /dev/null +++ b/playbooks/groups/proxies-haproxy.yml @@ -0,0 +1,18 @@ +- name: Set up all the haproxy stuff. + hosts: proxies-stg + user: root + gather_facts: True + + vars_files: + - /srv/web/infra/ansible/vars/global.yml + - "{{ private }}/vars.yml" + - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml + + handlers: + - include: "{{ handlers }}/restart_services.yml" + + roles: + + - role: haproxy/rewrite + website: admin.fedoraproject.org + path: /haproxy diff --git a/playbooks/groups/proxies.yml b/playbooks/groups/proxies.yml index 0f94521ce7..bb504200b8 100644 --- a/playbooks/groups/proxies.yml +++ b/playbooks/groups/proxies.yml @@ -82,4 +82,5 @@ - include: proxies-reverseproxy.yml - include: proxies-redirects.yml - include: proxies-fedora-web.yml +- include: proxies-haproxy.yml - include: proxies-miscellaneous.yml diff --git a/roles/haproxy/rewrite/tasks/main.yml b/roles/haproxy/rewrite/tasks/main.yml new file mode 100644 index 0000000000..8883367d8d --- /dev/null +++ b/roles/haproxy/rewrite/tasks/main.yml @@ -0,0 +1,6 @@ +- template: src=rewrite.conf dest=/etc/httpd.conf.d/{{website}}/haproxy.conf + notify: + - restart httpd + tags: + - haproxy + - haproxy/rewrite diff --git a/roles/haproxy/rewrite/templates/rewrite.conf b/roles/haproxy/rewrite/templates/rewrite.conf new file mode 100644 index 0000000000..7469e01c19 --- /dev/null +++ b/roles/haproxy/rewrite/templates/rewrite.conf @@ -0,0 +1,2 @@ +RewriteEngine On +RewriteRule ^{{path}}/(proxy\d+)((?:;.*)?) http://$1:8080/$2 [P,L]