From b5edddb606ab211f7c5a7ca1e4d49d7bf5aa013e Mon Sep 17 00:00:00 2001 From: Masroor Ehsan Date: Mon, 27 Jan 2025 10:57:22 +0600 Subject: [PATCH] split nginx into different configs --- .env | 3 ++- config/ohif/nginx.conf | 28 ---------------------------- config/ohif/nginx/default.conf | 5 +++++ config/ohif/nginx/ohif.conf | 32 ++++++++++++++++++++++++++++++++ docker-compose.yml | 16 +++++++++++++--- 5 files changed, 52 insertions(+), 32 deletions(-) delete mode 100644 config/ohif/nginx.conf create mode 100644 config/ohif/nginx/default.conf create mode 100644 config/ohif/nginx/ohif.conf diff --git a/.env b/.env index 569744d..1463927 100644 --- a/.env +++ b/.env @@ -1,7 +1,8 @@ # # Nginx configuration # -NGINX_DEFAULT_CONF=./config/ohif/nginx.conf +NGINX_DEFAULT_CONF=./config/ohif/nginx/default.conf +NGINX_OHIF_CONF=./config/ohif/nginx/ohif.conf # # OHIF Viewer diff --git a/config/ohif/nginx.conf b/config/ohif/nginx.conf deleted file mode 100644 index 522e5d8..0000000 --- a/config/ohif/nginx.conf +++ /dev/null @@ -1,28 +0,0 @@ -server { - listen 80; - # set client body size to 500M, this is to allow uploading of DICOMs, throws '413 request entity too large nginx' error otherwise # - client_max_body_size 500M; - location / { - root /usr/share/nginx/html; - index index.html index.htm; - try_files $uri $uri/ /index.html; - } - - error_page 500 502 503 504 /50x.html; - - location = /50x.html { - root /usr/share/nginx/html; - } - - # https://book.orthanc-server.com/faq/nginx.html#nginx - location /orthanc/ { - proxy_pass http://orthanc:8042; - proxy_set_header HOST $host; - proxy_set_header X-Real-IP $remote_addr; - rewrite /orthanc(.*) $1 break; - add_header 'Access-Control-Allow-Credentials' 'true'; - add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; - add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; - add_header 'Access-Control-Allow-Origin' '*'; - } -} diff --git a/config/ohif/nginx/default.conf b/config/ohif/nginx/default.conf new file mode 100644 index 0000000..1d884cc --- /dev/null +++ b/config/ohif/nginx/default.conf @@ -0,0 +1,5 @@ +server { + listen 80; + include /etc/nginx/enabled-sites/*.conf; + client_max_body_size 250M; +} diff --git a/config/ohif/nginx/ohif.conf b/config/ohif/nginx/ohif.conf new file mode 100644 index 0000000..44976a6 --- /dev/null +++ b/config/ohif/nginx/ohif.conf @@ -0,0 +1,32 @@ +location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html; + + add_header Cross-Origin-Opener-Policy same-origin; + add_header Cross-Origin-Embedder-Policy require-corp; + add_header Cross-Origin-Resource-Policy same-origin; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto; +} + +error_page 500 502 503 504 /50x.html; + +location = /50x.html { + root /usr/share/nginx/html; +} + +# https://book.orthanc-server.com/faq/nginx.html#nginx +location /orthanc/ { + proxy_pass http://orthanc:8042; + proxy_set_header HOST $host; + proxy_set_header X-Real-IP $remote_addr; + rewrite /orthanc(.*) $1 break; + + add_header 'Access-Control-Allow-Credentials' 'true'; + add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + add_header 'Access-Control-Allow-Origin' '*'; +} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 05100b0..7c2bd11 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,11 +16,20 @@ services: volumes: - ${POSTGRES_DATA_MNT}:${PGDATA} healthcheck: - test: ["CMD", "pg_isready", "-q", "-d", "${POSTGRES_DB}", "-U", "${POSTGRES_USER}"] + test: + [ + "CMD", + "pg_isready", + "-q", + "-d", + "${POSTGRES_DB}", + "-U", + "${POSTGRES_USER}", + ] start_period: 20s interval: 30s retries: 5 - timeout: 5s + timeout: 5s restart: unless-stopped pgadmin: @@ -75,6 +84,7 @@ services: - APP_CONFIG=/usr/share/nginx/html/app-config.js volumes: - ${NGINX_DEFAULT_CONF}:/etc/nginx/conf.d/default.conf:ro + - ${NGINX_OHIF_CONF}:/etc/nginx/enabled-sites/ohif.conf:ro - ${OHIF_CONFIG}:/usr/share/nginx/html/app-config.js:ro - ${OHIF_LOGO}:/usr/share/nginx/html/logo.png:ro restart: unless-stopped @@ -100,4 +110,4 @@ services: networks: pacs: - external: true \ No newline at end of file + external: true