diff --git a/README.md b/README.md index caeed85..7fa0525 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ This repository currently manages these services: - Several buildbot-workers - IP address wizard at [config.berlin.freifunk.net](https://config.berlin.freifunk.net/) - The vpn03 servers which route our traffic to the internet +- The public site for the berlin community at [berlin.freifunk.net](https://berlin.freifunk.net/) ## Requirements diff --git a/inventory/host_vars/berlin.freifunk.net b/inventory/host_vars/berlin.freifunk.net new file mode 100644 index 0000000..bfdf58e --- /dev/null +++ b/inventory/host_vars/berlin.freifunk.net @@ -0,0 +1,2 @@ +--- +caddy_caddyfile: Caddyfile_website.j2 diff --git a/inventory/hosts b/inventory/hosts index 3359ebc..83977cd 100644 --- a/inventory/hosts +++ b/inventory/hosts @@ -34,3 +34,5 @@ download-master.berlin.freifunk.net [uisp] uisp.berlin.freifunk.net ansible_host=10.31.130.158 # New uisp VM +[website] +berlin.freifunk.net diff --git a/play.yml b/play.yml index 1b74c34..cc1de31 100644 --- a/play.yml +++ b/play.yml @@ -55,3 +55,9 @@ - tunneldigger tags: - tunneldigger + +- name: Set up website + hosts: website + become: true + roles: + - caddy diff --git a/templates/Caddyfile_website.j2 b/templates/Caddyfile_website.j2 new file mode 100644 index 0000000..fb40c13 --- /dev/null +++ b/templates/Caddyfile_website.j2 @@ -0,0 +1,113 @@ +# www redirect +www.berlin.freifunk.net { + redir https://berlin.freifunk.net{uri} +} + +# production +berlin.freifunk.net { + root * /srv/www/berlin.freifunk.net + encode gzip + + @de_before_en { + header_regexp Accept-Language de.*en + path / + } + @en_before_de { + header_regexp Accept-Language en.*de + path / + } + @de_only { + header_regexp Accept-Language de + path / + } + @fallback { + path / + } + + redir @de_before_en /de 302 + redir @en_before_de /en 302 + redir @de_only /de 302 + redir @fallback /en 302 + + redir /index_en /en 301 + redir /network /de/map 301 + redir /contact /de/contact/ 301 + redir /contact_en /en/contact 301 + redir /download /de/downloads 301 + redir /participate/ /de/participate 301 + redir /p /de/participate 301 + redir /impressum /de/impressum 301 + redir /wiki /de/wiki 301 + redir /meshwiki /de/wiki 301 + + file_server +} + +# development +dev.berlin.freifunk.net { + root * /srv/www/dev.berlin.freifunk.net + encode gzip + + @de_before_en { + header_regexp Accept-Language de.*en + path_regexp branch ^\/([[:alnum:]]+)(\/$|$) + } + @en_before_de { + header_regexp Accept-Language en.*de + path_regexp branch ^\/([[:alnum:]]+)(\/$|$) + } + @de_only { + header_regexp Accept-Language de + path_regexp branch ^\/([[:alnum:]]+)(\/$|$) + } + @fallback { + path_regexp branch ^\/([[:alnum:]]+)(\/$|$) + } + + redir @de_before_en /{re.branch.1}/de 302 + redir @en_before_de /{re.branch.1}/en 302 + redir @de_only /{re.branch.1}/de 302 + redir @fallback /{re.branch.1}/en 302 + + @index_en { + path_regexp branch ^\/([[:alnum:]]+)\/index\_en + } + redir @index_en /{re.branch.1}/en 301 + + @network { + path_regexp branch ^\/([[:alnum:]]+)\/network + } + redir @network /{re.branch.1}/de/map 301 + + @contact { + path_regexp branch ^\/([[:alnum:]]+)\/contact + } + redir @contact /{re.branch.1}/de/contact 301 + + @contact_en { + path_regexp branch ^\/([[:alnum:]]+)\/contact_en + } + redir @contact_en /{re.branch.1}/en/contact 301 + + @download { + path_regexp branch ^\/([[:alnum:]]+)\/download + } + redir @download /{re.branch.1}/de/downloads 301 + + @participate { + path_regexp branch ^\/([[:alnum:]]+)\/(participate|p$) + } + redir @participate /{re.branch.1}/de/participate 301 + + @impressum { + path_regexp branch ^\/([[:alnum:]]+)\/impressum + } + redir @impressum /{re.branch.1}/de/impressum 301 + + @wiki { + path_regexp branch ^\/([[:alnum:]]+)\/(meshwiki|wiki) + } + redir @wiki /{re.branch.1}/de/wiki 301 + + file_server +}