Initial commit
This commit is contained in:
commit
a4ac8e4ae8
19
meta/main.yml
Normal file
19
meta/main.yml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
- re.nemunai.nginx-config-svc
|
||||||
|
|
||||||
|
galaxy_info:
|
||||||
|
role_name: nginx-config-s3svc
|
||||||
|
author: 'Pierre-Olivier Mercier <nemunaire+iac@nemunai.re>'
|
||||||
|
description: Abstraction to configure nginx server for a static website stored on S3
|
||||||
|
license: GPL-3.0-or-later
|
||||||
|
min_ansible_version: 2.9
|
||||||
|
platforms:
|
||||||
|
- name: Alpine
|
||||||
|
versions:
|
||||||
|
- all
|
||||||
|
- name: Debian
|
||||||
|
versions:
|
||||||
|
- all
|
||||||
|
galaxy_tags: []
|
38
tasks/main.yml
Normal file
38
tasks/main.yml
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
---
|
||||||
|
- ansible.builtin.blockinfile:
|
||||||
|
path: /etc/nginx/nginx.conf
|
||||||
|
block: |
|
||||||
|
upstream storage_nemunaire {
|
||||||
|
{% for server in s3_hosts %}
|
||||||
|
server {{ server.host }}:{{ server.port | default(9000) }}{% if server.backup is defined and server.backup %} backup{% endif %};
|
||||||
|
{% endfor %}
|
||||||
|
}
|
||||||
|
insertafter: 'http {'
|
||||||
|
marker: "# {mark} ANSIBLE MANAGED BLOCK storage_nemunaire"
|
||||||
|
|
||||||
|
- ansible.builtin.set_fact:
|
||||||
|
server: |
|
||||||
|
location / {
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_set_header Host $http_host;
|
||||||
|
proxy_connect_timeout 300;
|
||||||
|
# Default is HTTP/1, keepalive is only enabled in HTTP/1.1
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Connection "";
|
||||||
|
proxy_set_header Authorization "";
|
||||||
|
proxy_intercept_errors on;
|
||||||
|
chunked_transfer_encoding off;
|
||||||
|
proxy_pass https://storage_nemunaire/{{ bucket }}{{ path }}/;
|
||||||
|
|
||||||
|
error_page 404 /err.html;
|
||||||
|
#try_files $uri $uri/index.html $uri.html =404;
|
||||||
|
}
|
||||||
|
location ~ /$ {
|
||||||
|
rewrite ^(.*)/ $1/index.html;
|
||||||
|
}
|
||||||
|
when: server is not defined
|
||||||
|
|
||||||
|
- ansible.builtin.include_role:
|
||||||
|
name: re.nemunai.nginx-config-svc
|
Loading…
Reference in New Issue
Block a user