Skip to content
Snippets Groups Projects
Commit b230d205 authored by FORESTIER Fabien's avatar FORESTIER Fabien
Browse files

Improve nginx routing

parent 5f27e167
No related branches found
No related tags found
No related merge requests found
......@@ -2,8 +2,8 @@ version: "2"
services:
node-server:
build: ./webapp
# node-server:
# build: ./webapp
proxy-elasticsearch:
image: nginx
......
......@@ -2,30 +2,34 @@
server {
listen 8080;
server_name portail-data;
root /usr/share/nginx/html;
root /usr/share/nginx/html/;
location = / {
rewrite_by_lua '
for lang in (ngx.var.http_accept_language .. ","):gmatch("([^,]*),") do
if string.sub(lang, 0, 2) == "en" then
ngx.redirect("/en/")
end
if string.sub(lang, 0, 2) == "fr" then
ngx.redirect("/fr/")
end
end
ngx.redirect("/en/")
';
#rewrite ^/$ /en/ permanent;
location = / {
rewrite_by_lua '
for lang in (ngx.var.http_accept_language .. ","):gmatch("([^,]*),") do
if string.sub(lang, 0, 2) == "en" then
ngx.redirect("/en/")
end
if string.sub(lang, 0, 2) == "fr" then
ngx.redirect("/fr/")
end
end
ngx.redirect("/en/")
';
#rewrite ^/$ /en/ permanent;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
error_page 404 = @notfound;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location @notfound {
return 301 /;
location /en/ {
try_files $uri$args $uri/ /en/index.html;
}
location /fr/ {
try_files $uri$args $uri/ /fr/index.html;
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment