Skip to content

Commit

Permalink
Merge pull request #1094 from ORCID/feature/nginx_ensure_locale_stays…
Browse files Browse the repository at this point in the history
…_visible_in_uri_path

Feature/nginx ensure locale stays visible in uri path
  • Loading branch information
jthomas-orcid authored Jan 22, 2024
2 parents fb78b29 + 0fc1b99 commit 3b9b668
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 45 deletions.
59 changes: 26 additions & 33 deletions ui/container-files/etc/nginx/conf.d/default.conf
Original file line number Diff line number Diff line change
@@ -1,43 +1,36 @@
map $cookie_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;
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;
listen 8090;
server_name localhost;

#access_log /var/log/nginx/host.access.log main;
# Uncomment logfile entries for debug of requests recieved by this virtual host.
#access_log /var/log/nginx/host.access.log main;
#error_log /var/log/nginx/host.access.log notice;

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/(.*)$ /${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/ /${langCode}/index.html?$args;

# Or use the following line instead
# auto-index on;
}
location / {
root /usr/share/nginx/html;
index index.html index.htm;

# Requires base href {in the index.html files} be set to "./" or "/ui/<langCode>/" e.g "/ui/it/" or "/ui/en/" #############################################################
location ~ ^/(cs|de|en|es|fr|it|ja|ko|pt|ru|zh-CN|zh-TW)/(.*) {
try_files $uri $uri/ /$1/index.html?$args;
}

}
}

}
24 changes: 12 additions & 12 deletions ui/container-files/etc/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@ error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
worker_connections 1024;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

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

sendfile on;
#tcp_nopush on;
sendfile on;
#tcp_nopush on;

keepalive_timeout 65;
keepalive_timeout 65;

#gzip on;
#gzip on;

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

}

0 comments on commit 3b9b668

Please sign in to comment.