Skip to content
Snippets Groups Projects
Commit d6f15d42 authored by ynerant's avatar ynerant Committed by ynerant
Browse files

[nginx/cas] Factorize nginx configuration


Signed-off-by: ynerant's avatarYohann D'ANELLO <ynerant@crans.org>
parent 82119c74
No related branches found
No related tags found
1 merge request!165Nginx
......@@ -2,13 +2,6 @@
glob_django_cas:
repo: 'http://gitlab.adm.crans.org/nounous/django-cas.git'
path: '/var/local/django-cas'
url:
- cas.crans.org
- cas.adm.crans.org
- login.crans.org
- login.adm.crans.org
- auth.crans.org
- auth.adm.crans.org
ldap:
dn: 'cn=Utilisateurs,dc=crans,dc=org'
password: "{{ vault.cas_ldap_password }}"
......@@ -18,6 +11,30 @@ glob_django_cas:
host: tealc.adm.crans.org
password: "{{ vault.cas_database_password }}"
secret_key: "{{ vault.cas_secret_key }}"
reverse_proxy:
- '10.231.136.0/24'
- '2a0c:700:0:2::/64'
loc_nginx:
service_name: "cas"
ssl: []
servers:
- server_name:
- cas.crans.org
- cas.adm.crans.org
- login.crans.org
- login.adm.crans.org
- auth.crans.org
- auth.adm.crans.org
default: true
locations:
- filter: "/cas"
params:
- "rewrite ^/cas$ / redirect"
- "rewrite ^/cas/(.*)$ /$1 redirect"
- filter: "/static"
params:
- "alias /var/local/django-cas/cas/local_static"
- filter: "/"
params:
- "uwsgi_pass unix:///var/run/uwsgi/app/cas/socket"
- "include uwsgi_params"
......@@ -88,6 +88,7 @@ monitoring.adm.crans.org
charybde.adm.crans.org
[nginx:children]
django_cas
mailman
reverseproxy
roundcube
......
......@@ -5,5 +5,7 @@
- hosts: django_cas
vars:
django_cas: "{{ glob_django_cas | default({}) | combine(loc_django_cas | default({})) }}"
nginx: "{{ glob_nginx | default({}) | combine(loc_nginx | default({})) }}"
roles:
- django-cas
- nginx
---
- name: Restart nginx
service:
name: nginx
state: restarted
- name: Restart uwsgi
service:
name: uwsgi
......
......@@ -3,7 +3,6 @@
apt:
update_cache: true
name:
- nginx
- uwsgi
- uwsgi-plugin-python3
- python3-django
......@@ -30,20 +29,6 @@
owner: www-data
notify: Restart uwsgi
- name: Configure NGINX site
template:
src: nginx/sites-available/cas.j2
dest: /etc/nginx/sites-available/cas
mode: 0644
notify: Restart nginx
- name: Enable nginx site
file:
src: /etc/nginx/sites-available/cas
dest: /etc/nginx/sites-enabled/cas
state: link
notify: Restart nginx
- name: Configure UWSGI app
template:
src: uwsgi/apps-available/cas.ini.j2
......
{{ ansible_header | comment }}
server {
server_name {{ django_cas.url | join(' ') }};
listen 80;
listen [::]:80;
location /cas {
rewrite ^/cas$ / redirect;
rewrite ^/cas/(.*)$ /$1 redirect;
}
location /static {
alias {{ django_cas.path }}/cas/local_static;
}
{% for ip in django_cas.reverse_proxy | default([]) %}
set_real_ip_from {{ ip }};
{% endfor %}
real_ip_header P-Real-Ip;
location / {
uwsgi_pass unix:///var/run/uwsgi/app/cas/socket;
include uwsgi_params;
}
}
---
- name: Restart nginx
service:
name: nginx
state: restarted
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment