From 74ee26c8d65dbe2149bb2bfa50ab5702a75e3227 Mon Sep 17 00:00:00 2001 From: fry Date: Thu, 10 Mar 2022 19:26:50 -0500 Subject: [PATCH] Add nginx so we can make requests to our from the FE without CORS issues (#3) Co-authored-by: David Frymoyer Reviewed-on: https://git.saintnet.tech/stryan/freego_api/pulls/3 Co-authored-by: fry Co-committed-by: fry --- docker-compose.yml | 6 +++++- nginx/Dockerfile | 3 +++ nginx/nginx.conf | 17 +++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 nginx/Dockerfile create mode 100644 nginx/nginx.conf diff --git a/docker-compose.yml b/docker-compose.yml index c4a5f21..6954a22 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,4 +6,8 @@ services: api: build: . ports: - - 1379:1379 \ No newline at end of file + - 1379:1379 + web: + build: nginx + ports: + - 80:80 \ No newline at end of file diff --git a/nginx/Dockerfile b/nginx/Dockerfile new file mode 100644 index 0000000..6a95a6f --- /dev/null +++ b/nginx/Dockerfile @@ -0,0 +1,3 @@ +FROM nginx:latest AS base + +COPY ./nginx.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/nginx/nginx.conf b/nginx/nginx.conf new file mode 100644 index 0000000..e0d4cb9 --- /dev/null +++ b/nginx/nginx.conf @@ -0,0 +1,17 @@ +server { + listen 80; + server_name steve; + + location / { + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_pass http://ui:3000; + } + + location /api/ { + rewrite ^/api(/.*)$ $1 break; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_pass http://api:1379; + } +} \ No newline at end of file