From 5108aa0351d0cdbf426290ed91e99904d1e0572a Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Tue, 16 Jun 2015 17:15:24 +0000 Subject: [PATCH] Serve it all with nginx. --- roles/taiga/files/taiga.nginx | 46 +++++++++++++++++++++++++++++++++++ roles/taiga/tasks/main.yml | 17 +++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 roles/taiga/files/taiga.nginx diff --git a/roles/taiga/files/taiga.nginx b/roles/taiga/files/taiga.nginx new file mode 100644 index 0000000000..125a7666d7 --- /dev/null +++ b/roles/taiga/files/taiga.nginx @@ -0,0 +1,46 @@ +server { + listen 80 default_server; + server_name _; + + large_client_header_buffers 4 32k; + client_max_body_size 50M; + charset utf-8; + + # Frontend + location / { + root /home/taiga/taiga-front-dist/dist/; + try_files $uri $uri/ /index.html; + } + + # Backend + location /api { + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Scheme $scheme; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_pass http://127.0.0.1:8001/api; + proxy_redirect off; + } + + # Django admin access (/admin/) + location /admin { + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Scheme $scheme; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_pass http://127.0.0.1:8001$request_uri; + proxy_redirect off; + } + + # Static files + location /static { + alias /home/taiga/taiga-back/static; + } + + # Media files + location /media { + alias /home/taiga/taiga-back/media; + } +} diff --git a/roles/taiga/tasks/main.yml b/roles/taiga/tasks/main.yml index d740dd6e61..9b817edf2e 100644 --- a/roles/taiga/tasks/main.yml +++ b/roles/taiga/tasks/main.yml @@ -166,3 +166,20 @@ state=link tags: taiga ### DONE with taiga-front + +### FINALLY, nginx to serve/proxy it all +- copy: src=taiga.nginx dest=/etc/nginx/sites-available/taiga + mode=0644 owner=nginx group=nginx + notify: restart nginx + tags: taiga + +- file: dest=/etc/nginx/site-enabled/default state=absent + notify: restart nginx + tags: taiga + +- file: src=/etc/nginx/sites-available/taiga dest=/etc/nginx/site-enabled/taiga state=link + notify: restart nginx + tags: taiga + +- service: name=nginx state=running enabled=yes + tags: taiga