mirror of
https://github.com/HanXHX/ansible-nginx.git
synced 2026-02-24 09:03:29 +07:00
First shot proxy (unstable)
This commit is contained in:
@@ -43,6 +43,7 @@ server {
|
||||
deny all;
|
||||
}
|
||||
|
||||
{% block template_local_content %}
|
||||
location = /favicon.ico {
|
||||
expires 30d;
|
||||
access_log off;
|
||||
@@ -53,6 +54,7 @@ server {
|
||||
expires 30d;
|
||||
log_not_found off;
|
||||
}
|
||||
{% endblock %}
|
||||
|
||||
{% if __location is iterable and __location | length > 0 %}
|
||||
# --> Custom locations
|
||||
|
||||
23
templates/etc/nginx/sites-available/_proxy.j2
Normal file
23
templates/etc/nginx/sites-available/_proxy.j2
Normal file
@@ -0,0 +1,23 @@
|
||||
{% extends "_base.j2" %}
|
||||
|
||||
{% block template_try_files %}
|
||||
proxy_set_header Host $host;
|
||||
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_pass http://{{ item.upstream_name }};
|
||||
proxy_read_timeout 90;
|
||||
|
||||
{#proxy_redirect http://{{ upstream.name }} https://jenkins.domain.tld;#}
|
||||
|
||||
{% if item.proxy_params is defined and item.proxy_params is iterable %}
|
||||
{% for param in item.proxy_params %}
|
||||
{{ param }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{# We flush the default local content (locations) #}
|
||||
{% block template_local_content %}
|
||||
{% endblock %}
|
||||
19
templates/etc/nginx/upstream/upstream.conf.j2
Normal file
19
templates/etc/nginx/upstream/upstream.conf.j2
Normal file
@@ -0,0 +1,19 @@
|
||||
{%- macro s(key, value, is_bool, min_version) %}
|
||||
{% if nginx_version.stdout | version_compare(min_version, 'ge') %}
|
||||
{% if is_bool and value %} {{ key }}{% else %} {{ key }}={{ value }}{% endif %}
|
||||
{% endif %}
|
||||
{%- endmacro -%}
|
||||
#
|
||||
# {{ ansible_managed }}
|
||||
#
|
||||
|
||||
upstream {{ item.name }} {
|
||||
{% for server in item.servers %}
|
||||
server {{ server.name }}{% for p in nginx_upstream_server_params if server[p.key] is defined %}{{ s(p.key, server[p.key] | default(p.default), p.is_bool | default(false), p.min_version | default('0.0.1')) }}{% endfor %};
|
||||
{% endfor %}
|
||||
{% if item.params is defined and item.params is iterable %}
|
||||
{% for param in item.params %}
|
||||
{{ param }};
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
}
|
||||
Reference in New Issue
Block a user