Integrated automatic locale redirect (#33)
This commit is contained in:
Родитель
038e13faf4
Коммит
1900e90c2c
16
Dockerfile
16
Dockerfile
|
@ -2,13 +2,15 @@ FROM alpine:edge
|
|||
EXPOSE 80
|
||||
|
||||
RUN apk update && \
|
||||
apk add \
|
||||
caddy \
|
||||
mailcap && \
|
||||
rm -rf \
|
||||
/var/cache/apk/*
|
||||
apk add wget mailcap ca-certificates && \
|
||||
rm -rf /var/cache/apk/* && \
|
||||
wget -O /tmp/caddy.tar.gz "https://caddyserver.com/download/build?os=linux&arch=amd64&features=locale%2Csearch" && \
|
||||
mkdir -p /tmp/caddy && \
|
||||
tar xvzf /tmp/caddy.tar.gz -C /tmp/caddy && \
|
||||
cp /tmp/caddy/caddy /usr/sbin/caddy && \
|
||||
rm -rf /tmp/caddy*
|
||||
|
||||
CMD ["/usr/sbin/caddy", "-conf", "/etc/caddy/caddy.conf"]
|
||||
CMD ["/usr/sbin/caddy", "-conf", "/etc/caddy.conf"]
|
||||
|
||||
COPY docker/caddy.conf /etc/caddy/caddy.conf
|
||||
COPY docker/caddy.conf /etc/caddy.conf
|
||||
COPY public /srv/www
|
||||
|
|
|
@ -1,7 +1,39 @@
|
|||
:80 {
|
||||
root /srv/www
|
||||
|
||||
errors {
|
||||
404 /404.html
|
||||
locale en-US zh-CN zh-TW pt-BR nl-NL {
|
||||
detect header
|
||||
}
|
||||
|
||||
redir 301 {
|
||||
if {path} match ^/$
|
||||
/ /{>Detected-Locale}/
|
||||
}
|
||||
|
||||
rewrite /en-US/ {
|
||||
regexp (.*)
|
||||
to /en-us/{1}
|
||||
}
|
||||
|
||||
rewrite /zh-CN/ {
|
||||
regexp (.*)
|
||||
to /zh-cn/{1}
|
||||
}
|
||||
|
||||
rewrite /zh-TW/ {
|
||||
regexp (.*)
|
||||
to /zh-tw/{1}
|
||||
}
|
||||
|
||||
rewrite /pt-BR/ {
|
||||
regexp (.*)
|
||||
to /pt-br/{1}
|
||||
}
|
||||
|
||||
rewrite /nl-NL/ {
|
||||
regexp (.*)
|
||||
to /nl-nl/{1}
|
||||
}
|
||||
|
||||
header / Vary "Accept-Language"
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче