From 79b974179e4f1cecfb7debe27365ab8580f7c6cf Mon Sep 17 00:00:00 2001 From: biharck Date: Wed, 24 Apr 2019 15:14:26 -0300 Subject: [PATCH] Adding proxy for orthanc --- .gitignore | 3 +- docker/docker-compose-orthanc.yml | 32 +++++++++++++++++++++ docker/nginx-proxy/conf/nginx.conf | 46 ++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 docker/docker-compose-orthanc.yml create mode 100644 docker/nginx-proxy/conf/nginx.conf diff --git a/.gitignore b/.gitignore index fe5064360..bb5a27d1a 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,5 @@ package-lock.json yarn-error.log .DS_Store -example/deps/ \ No newline at end of file +example/deps/ +sampledata/ \ No newline at end of file diff --git a/docker/docker-compose-orthanc.yml b/docker/docker-compose-orthanc.yml new file mode 100644 index 000000000..06a796248 --- /dev/null +++ b/docker/docker-compose-orthanc.yml @@ -0,0 +1,32 @@ +version: '3.5' + +services: + + orthanc: + container_name: orthanc + image: jodogne/orthanc-plugins + volumes: + - ../sampledata:/sampledata + ports: + - "4242:4242" + - "8042:8042" + restart: always + viewer: + container_name: ohif-viewer + build: + context: ../ + dockerfile: Dockerfile + ports: + - '80:80' + depends_on: + - orthanc + environment: + - NODE_ENV=production + restart: always + proxy: + image: nginx + restart: always + ports: + - 8899:80 + volumes: + - ./nginx-proxy/conf/nginx.conf:/etc/nginx/nginx.conf:ro diff --git a/docker/nginx-proxy/conf/nginx.conf b/docker/nginx-proxy/conf/nginx.conf new file mode 100644 index 000000000..bf1578919 --- /dev/null +++ b/docker/nginx-proxy/conf/nginx.conf @@ -0,0 +1,46 @@ +events { + worker_connections 4096; ## Default: 1024 +} + +http { + server { + listen 80 default_server; + server_name localhost; + + # + # Wide-open CORS config for nginx + # + location / { + if ($request_method = 'OPTIONS') { + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + # + # Custom headers and headers various browsers *should* be OK with but aren't + # + add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range'; + # + # Tell client that this pre-flight info is valid for 20 days + # + add_header 'Access-Control-Max-Age' 1728000; + add_header 'Content-Type' 'text/plain; charset=utf-8'; + add_header 'Content-Length' 0; + return 204; + } + if ($request_method = 'POST') { + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range'; + add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range'; + } + if ($request_method = 'GET') { + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range'; + add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range'; + } + + proxy_pass http://orthanc:8442; + } + + } +} \ No newline at end of file