From f1938666d1e0e16beb00722118e21a26a8408280 Mon Sep 17 00:00:00 2001
From: Hugo SUBTIL <ext.sopra.husubtil@grandlyon.com>
Date: Wed, 16 Dec 2020 13:25:28 +0100
Subject: [PATCH] fix: update nginx config

---
 nginx/dev.conf | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/nginx/dev.conf b/nginx/dev.conf
index 5998c8574..4265eb65e 100644
--- a/nginx/dev.conf
+++ b/nginx/dev.conf
@@ -1,25 +1,31 @@
+upstream api_node_js {
+	server	service-ram:3000;
+}
 
 server {
   listen 8080 default_server;
 
   root /usr/share/nginx/html;
+  index index.html;
 
   location / {
     # First attempt to serve request as file, then
     # as directory, then fall back to displaying a 404.
-    try_files $uri $uri/ /index.html;
+    try_files $uri $uri/ $uri/index.html @backend;
   }
 
-  location /api {
-    rewrite ^/api/(.*) /$1 break;
-    proxy_pass http://json-server:3000/api;
+  location @backend {
+    rewrite /api/?(.*) /$1 break;
+    proxy_pass http://api_node_js;
+    proxy_set_header   X-Forwarded-Proto $scheme;
+    proxy_set_header   X-Real-IP         $remote_addr;
   }
 
-  # Public api redirect
-    location /base-adresse/base-adresse-nationale/streets {
+  location /base-adresse/base-adresse-nationale/streets {
     proxy_pass https://passerelle.formulaireextranet.grandlyon.com/base-adresse/base-adresse-nationale/streets;
   }
 
+
   location /geocoding/photon/api {
     proxy_pass https://download.data.grandlyon.com/geocoding/photon/api;
   }
@@ -38,3 +44,4 @@ server {
   }
 
 }
+
-- 
GitLab