diff --git a/docker/files/etc/nginx/conf.d/00-collaboration-proxy-cache.conf b/docker/files/etc/nginx/conf.d/00-collaboration-proxy-cache.conf new file mode 100644 index 00000000..a39e3432 --- /dev/null +++ b/docker/files/etc/nginx/conf.d/00-collaboration-proxy-cache.conf @@ -0,0 +1 @@ +proxy_cache_path /tmp/auth_cache levels=1:2 keys_zone=auth_cache:10m inactive=60s max_size=100m; diff --git a/docker/files/etc/nginx/conf.d/default.conf b/docker/files/etc/nginx/conf.d/default.conf index e5967e33..e4821c00 100644 --- a/docker/files/etc/nginx/conf.d/default.conf +++ b/docker/files/etc/nginx/conf.d/default.conf @@ -1,4 +1,3 @@ - server { listen 8083; server_name localhost; @@ -6,6 +5,14 @@ server { # Proxy auth for collaboration server location /collaboration/ws/ { + if ($request_method = OPTIONS) { + add_header 'Access-Control-Allow-Origin' 'http://localhost:3000'; + add_header 'Access-Control-Allow-Credentials' 'true'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type'; + return 204; + } + # Collaboration Auth request configuration auth_request /collaboration-auth; auth_request_set $authHeader $upstream_http_authorization; @@ -34,6 +41,10 @@ server { } location /collaboration-auth { + proxy_cache auth_cache; + proxy_cache_key "$http_authorization"; + proxy_cache_valid 200 30s; + proxy_pass http://app-dev:8000/api/v1.0/documents/collaboration-auth/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -43,10 +54,11 @@ server { # Prevent the body from being passed proxy_pass_request_body off; proxy_set_header Content-Length ""; + proxy_set_header Accept "application/json"; proxy_set_header X-Original-Method $request_method; } - location /collaboration/api/ { + location /collaboration/api/ { # Collaboration server proxy_pass http://y-provider:4444; proxy_set_header Host $host; @@ -76,7 +88,7 @@ server { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Original-URL $request_uri; - + # Prevent the body from being passed proxy_pass_request_body off; proxy_set_header Content-Length "";