commit a4ac8e4ae82fb4f79dcbc87e6b4a93977d35b623 Author: Pierre-Olivier Mercier Date: Sun Mar 26 16:23:35 2023 +0200 Initial commit diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..2f8675b --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,19 @@ +--- + +dependencies: + - re.nemunai.nginx-config-svc + +galaxy_info: + role_name: nginx-config-s3svc + author: 'Pierre-Olivier Mercier ' + 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: [] diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..364eee2 --- /dev/null +++ b/tasks/main.yml @@ -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