This commit is contained in:
Alex Kotov 2023-08-30 16:12:15 +04:00
parent 10ef6f10c5
commit f99c2fc0bc
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
6 changed files with 26 additions and 3 deletions

View File

@ -4,3 +4,7 @@ nginx__remove_default: true
nginx__upstreams: []
nginx__sites: []
nginx__stream: ''
nginx__geoip_country: null
nginx__geoip_city: null
nginx__geoip2: []

View File

@ -1 +0,0 @@
geoip_country /usr/share/GeoIP/GeoIPv6.dat;

View File

@ -3,8 +3,8 @@
notify: nginx | Restart Nginx
apt:
name:
- geoip-database
- libnginx-mod-http-geoip
- libnginx-mod-http-geoip2
- nginx
- name: Create directories for Nginx configuration
@ -46,7 +46,7 @@
- name: Install Nginx configs
notify: nginx | Restart Nginx
template:
src: 'files/conf.d/geoip.conf'
src: 'templates/conf.d/geoip.conf'
dest: '{{ nginx__confd_dir }}/geoip.conf'
mode: 'u=rw,go=r'
owner: root

View File

@ -5,6 +5,7 @@
purge: true
name:
- libnginx-mod-http-geoip
- libnginx-mod-http-geoip2
- nginx
- nginx-common
- nginx-core

View File

@ -5,6 +5,7 @@
purge: false
name:
- libnginx-mod-http-geoip
- libnginx-mod-http-geoip2
- nginx
- nginx-common
- nginx-core

View File

@ -0,0 +1,18 @@
{% if nginx__geoip_country %}
geoip_country {{ nginx__geoip_country }};
{% else %}
#geoip_country path/to/GeoIP.dat;
{% endif %}
{% if nginx__geoip_city %}
geoip_city {{ nginx__geoip_city }};
{% else %}
#geoip_city path/to/GeoLiteCity.dat;
{% endif %}
{% for geoip2 in nginx__geoip2 %}
geoip2 {{ geoip2.file }} {
{% for map in geoip2.maps %}
${{ map.var }} {{ map.path }};
{% endfor %}
}
{% endfor %}