fix directory
This commit is contained in:
20
ansible/roles/nginx_proxy/tasks/main.yml
Normal file
20
ansible/roles/nginx_proxy/tasks/main.yml
Normal file
@ -0,0 +1,20 @@
|
||||
- name: Install Nginx
|
||||
zypper:
|
||||
name: nginx
|
||||
state: present
|
||||
|
||||
- name: Ensure Nginx is enabled and started
|
||||
systemd:
|
||||
name: nginx
|
||||
enabled: yes
|
||||
state: started
|
||||
|
||||
- name: Deploy Proxy Configuration
|
||||
template:
|
||||
src: proxy.conf.j2
|
||||
dest: /etc/nginx/conf.d/proxy.conf
|
||||
|
||||
- name: Reload Nginx
|
||||
systemd:
|
||||
name: nginx
|
||||
state: reloaded
|
26
ansible/roles/nginx_proxy/templates/proxy.conf.j2
Normal file
26
ansible/roles/nginx_proxy/templates/proxy.conf.j2
Normal file
@ -0,0 +1,26 @@
|
||||
upstream backend {
|
||||
{% for server in upstream_servers %}
|
||||
server {{ server }} max_fails=3 fail_timeout=30s;
|
||||
{% endfor %}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
listen 443 ssl;
|
||||
server_name {{ proxy.proxy_domain }};
|
||||
|
||||
ssl_certificate /etc/nginx/ssl/{{ ssl_cert_file }};
|
||||
ssl_certificate_key /etc/nginx/ssl/{{ ssl_key_file }};
|
||||
|
||||
location / {
|
||||
proxy_pass http://backend;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
|
||||
location /health {
|
||||
return 200 'Proxy is up';
|
||||
add_header Content-Type text/plain;
|
||||
}
|
||||
}
|
3
ansible/roles/nginx_proxy/vars/main.yml
Normal file
3
ansible/roles/nginx_proxy/vars/main.yml
Normal file
@ -0,0 +1,3 @@
|
||||
upstream_servers:
|
||||
- "{{ siteA.site_ip }}"
|
||||
- "{{ siteB.site_ip }}"
|
Reference in New Issue
Block a user