Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config for the website #119

Merged
merged 6 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions inventory/host_vars/web.berlin.freifunk.net
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
caddy_caddyfile: Caddyfile_website.j2
2 changes: 2 additions & 0 deletions inventory/hosts
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ download-master.berlin.freifunk.net
[uisp]
uisp.berlin.freifunk.net ansible_host=10.31.130.158 # New uisp VM

[website]
web.berlin.freifunk.net ansible_host=77.87.50.13
6 changes: 6 additions & 0 deletions play.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@
- tunneldigger
tags:
- tunneldigger

- name: Set up website
hosts: website
become: true
roles:
- caddy
113 changes: 113 additions & 0 deletions templates/Caddyfile_website.j2
Original file line number Diff line number Diff line change
@@ -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
}