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

Feature/nginx config for cookie locale #1088

Merged
merged 3 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 2 additions & 3 deletions ui/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ WORKDIR /app
# Install some useful utils for debug/test
RUN \
apt-get update && \
apt -y install python3 make gcc g++ && \
apt -y install python3 make gcc g++ vim && \
rm -rf /var/lib/apt/lists/*

# Install app dependencies
Expand All @@ -19,8 +19,7 @@ COPY package*.json ./

RUN \
npm config list && \
npm config delete proxy && \
npm install --loglevel silly
npm install

# Bundle app source
COPY . .
Expand Down
25 changes: 18 additions & 7 deletions ui/container-files/etc/nginx/conf.d/default.conf
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
map $ccokie_locale $langCode {
default en;
~*^cs cs;
~*^de de;
~*^es es;
~*^fr fr;
~*^it it;
~*^ja ja;
~*^ko ko;
~*^pt pt;
~*^ru ru;
~*^ui ui;
~*^zh-CN zh-CN;
~*^zh-TW zh-TW;
}

server {
listen 8090;
server_name localhost;

#access_log /var/log/nginx/host.access.log main;

# Fallback to default language if no preference defined by browser
if ($accept_language ~ "^$") {
set $accept_language "en";
}

location / {
root /usr/share/nginx/html;
index index.html index.htm;

location ~ ^/ui/(.*) {
# Redirect requests for `/ui/(.*)` to the Angular application in the preferred language of the browser
# For reference on multi language support see: https://angular.io/guide/i18n-common-deploy#configure-a-server
rewrite ^/ui/(.*)$ /$accept_language/$1 break;
rewrite ^/ui/(.*)$ /${langCode}/$1 break;

# Configure a fallback route in the NGinX server to serve the index.html when requests arrive for `/ui/login`
# Requires static html content to have a `base-href=./` entry
try_files $uri $uri/ /$accept_language/index.html?$args;
try_files $uri $uri/ /${langCode}/index.html?$args;

# Or use the following line instead
# auto-index on;
Expand Down
18 changes: 0 additions & 18 deletions ui/container-files/etc/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,6 @@ http {

#gzip on;

# Browser preferred language detection (does NOT require AcceptLanguageModule)
# For reference on multi language support see: https://angular.io/guide/i18n-common-deploy#configure-a-server
map $http_accept_language $accept_language {
default en;
~*^cs cs;
~*^de de;
~*^es es;
~*^fr fr;
~*^it it;
~*^ja ja;
~*^ko ko;
~*^pt pt;
~*^ru ru;
~*^ui ui;
~*^zh-CN zh-CN;
~*^zh-TW zh-TW;
}

include /etc/nginx/conf.d/*.conf;

}
Loading