From 1ff3d9c54eb575260abe18c33048461f44ad5b94 Mon Sep 17 00:00:00 2001 From: Anthony LC Date: Thu, 29 Aug 2024 16:42:29 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB(ngnix)=20add?= =?UTF-8?q?=20conf=20ngnix=20to=20proxy=20media=20url?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In development mode with docker-compose, we need to configure Nginx to proxy requests to the Minio server. Before to proxy to Minio, we need to authenticate the request, so we proxy to the Django server first to fill the request with the necessary headers, then we proxy to Minio. --- docker/files/etc/nginx/conf.d/default.conf | 30 ++++++++++++++++++++++ src/frontend/apps/impress/.env.development | 1 + 2 files changed, 31 insertions(+) diff --git a/docker/files/etc/nginx/conf.d/default.conf b/docker/files/etc/nginx/conf.d/default.conf index f4886b87..42559655 100644 --- a/docker/files/etc/nginx/conf.d/default.conf +++ b/docker/files/etc/nginx/conf.d/default.conf @@ -4,6 +4,36 @@ server { server_name localhost; charset utf-8; + location /media/ { + # Auth request configuration + auth_request /auth; + auth_request_set $authHeader $upstream_http_authorization; + auth_request_set $authDate $upstream_http_x_amz_date; + auth_request_set $authContentSha256 $upstream_http_x_amz_content_sha256; + + # Pass specific headers from the auth response + proxy_set_header Authorization $authHeader; + proxy_set_header X-Amz-Date $authDate; + proxy_set_header X-Amz-Content-SHA256 $authContentSha256; + + # Get resource from Minio + proxy_pass http://minio:9000/impress-media-storage/; + proxy_set_header Host minio:9000; + } + + location /auth { + proxy_pass http://app-dev:8000/api/v1.0/documents/retrieve-auth/; + 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-Original-URL $request_uri; + + # Prevent the body from being passed + proxy_pass_request_body off; + proxy_set_header Content-Length ""; + proxy_set_header X-Original-Method $request_method; + } + location / { proxy_pass http://keycloak:8080; proxy_set_header Host $host; diff --git a/src/frontend/apps/impress/.env.development b/src/frontend/apps/impress/.env.development index 2056c636..2186bc15 100644 --- a/src/frontend/apps/impress/.env.development +++ b/src/frontend/apps/impress/.env.development @@ -1,3 +1,4 @@ NEXT_PUBLIC_API_ORIGIN=http://localhost:8071 NEXT_PUBLIC_SIGNALING_URL=ws://localhost:4444 +NEXT_PUBLIC_MEDIA_URL=http://localhost:8083 NEXT_PUBLIC_SW_DEACTIVATED=true