Skip to content
Snippets Groups Projects
nginx.conf 821 B
Newer Older
  • Learn to ignore specific revisions
  • FORESTIER Fabien's avatar
    FORESTIER Fabien committed
        # staging server is listening on the port 8080
    
    FORESTIER Fabien's avatar
    FORESTIER Fabien committed
        root /usr/share/nginx/html/;
    
    
        # rule redirecting to fr or en regarding the browser preferences
    
    FORESTIER Fabien's avatar
    FORESTIER Fabien committed
        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/")
            ';
    
    FORESTIER Fabien's avatar
    FORESTIER Fabien committed
        # This is needed to allow reloading in the app when not on the base url as our app is an SPA
    
        location /en {
            try_files $uri$args /en/index.html;
    
        location /fr {
            try_files $uri$args /fr/index.html;