From 456b699177fedb841664488bd401fe838762086e Mon Sep 17 00:00:00 2001 From: tushar5526 Date: Wed, 9 Nov 2022 15:25:45 +0530 Subject: [PATCH 1/2] Add reverse proxy for /admin --- docker-compose.yml | 10 ++++++++++ next.config.js | 4 ++++ proxy-default.conf | 16 ++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 proxy-default.conf diff --git a/docker-compose.yml b/docker-compose.yml index 3ca9fa8..17d377b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -106,3 +106,13 @@ services: # volumes: # db_data: # fa_config: + + # proxy: + # image: nginx:latest + # container_name: nginx-proxy + # restart: unless-stopped + # ports: + # - 80:80 + # - 443:443 + # volumes: + # - ./proxy-default.conf:/etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/next.config.js b/next.config.js index ae88795..58337d8 100644 --- a/next.config.js +++ b/next.config.js @@ -1,7 +1,11 @@ /** @type {import('next').NextConfig} */ + +const isProd = process.env.NODE_ENV === 'production' + const nextConfig = { reactStrictMode: true, swcMinify: true, + assetPrefix: isProd ? '/admin' : undefined, } module.exports = nextConfig diff --git a/proxy-default.conf b/proxy-default.conf new file mode 100644 index 0000000..cc27e1e --- /dev/null +++ b/proxy-default.conf @@ -0,0 +1,16 @@ +server { + listen 80; + server_name localhost; + + location /admin/ { + proxy_pass http://portal:3000/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Scheme $scheme; + proxy_connect_timeout 5; + proxy_send_timeout 60; + proxy_read_timeout 70; + proxy_set_header X-Forwarded-Proto $scheme; + } + +} From 493ac9f26243c606da58b7a278a51e5656ec9b22 Mon Sep 17 00:00:00 2001 From: tushar5526 Date: Wed, 9 Nov 2022 15:41:06 +0530 Subject: [PATCH 2/2] Added a comment for assetPrefix --- next.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/next.config.js b/next.config.js index 58337d8..e6fc134 100644 --- a/next.config.js +++ b/next.config.js @@ -5,6 +5,7 @@ const isProd = process.env.NODE_ENV === 'production' const nextConfig = { reactStrictMode: true, swcMinify: true, + // "/admin" is the path we would use in the reverse proxy, so change accordingly if you want to use some other path assetPrefix: isProd ? '/admin' : undefined, }