From 6c3af75c5125cef093edebaa4d3ebec8f104fff7 Mon Sep 17 00:00:00 2001 From: Marius Date: Fri, 4 Nov 2016 18:53:21 +0100 Subject: [PATCH] Use nginx as reverse proxy in front of tusd --- .infra/Freyfile.hcl | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/.infra/Freyfile.hcl b/.infra/Freyfile.hcl index ec85472..a1cb1cf 100644 --- a/.infra/Freyfile.hcl +++ b/.infra/Freyfile.hcl @@ -172,6 +172,15 @@ setup { } } } + + playbooks { + hosts = "tusd" + name = "Setup nginx" + tasks { + name = "nginx | Add nginx PPA" + apt_repository = "repo='ppa:nginx/stable'" + } + } } deploy { @@ -194,19 +203,35 @@ deploy { file = "path={{{config.global.approot}}}/current/tusd_linux_amd64/tusd mode=0755 owner=www-data group=www-data" } } + playbooks { + hosts = "tusd" + name = "Deploy nginx" + roles { + role = "{{{init.paths.roles_dir}}}/apt/v1.0.0" + apt_packages = ["nginx-light"] + } + tasks { + name = "nginx | Create nginx configuration" + copy = "src=./files/nginx.conf dest=/etc/nginx/sites-enabled/default" + } + } } restart { playbooks { hosts = "tusd" name = "Restart tusd" - tasks { - shell = "iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080" - name = "tusd | Redirect HTTP traffic to tusd" - } tasks { action = "service name=tusd state=restarted" name = "tusd | Restart" } } + playbooks { + hosts = "nginx" + name = "Restart nginx" + tasks { + action = "service name=nginx state=restarted" + name = "nginx | Restart" + } + } }