From 49a6bb11a86fdd4eaff805a0160334ba9399265b Mon Sep 17 00:00:00 2001 From: "mathieu.brunot" Date: Mon, 18 Feb 2019 00:01:55 +0100 Subject: [PATCH] :bug: Fix NGINX default config --- frontend/docker-nginx/conf.d/default.conf | 39 +++++++++++++---------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/frontend/docker-nginx/conf.d/default.conf b/frontend/docker-nginx/conf.d/default.conf index e21a790c3..df1d0ed4b 100644 --- a/frontend/docker-nginx/conf.d/default.conf +++ b/frontend/docker-nginx/conf.d/default.conf @@ -1,9 +1,9 @@ # This will load balance your backend to one or more destinations. -upstream backend { +upstream uxboxbackend { # server api1.uxbox.{{ DOMAIN }}:3000; # server api1.uxbox.{{ DOMAIN }}:3001; # server api2.uxbox.{{ DOMAIN }}:3000; - server uxbackend:6060; # This is a circular reference that allows docker to start as the example project, it is not recommended to use this in actual development. + server uxbackend:6060; # This is a circular reference that allows docker to start as the example project } server { @@ -23,12 +23,28 @@ server { #ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH"; #ssl_prefer_server_ciphers on; - #server_name uxbox.{{ DOMAIN }}; + #server_name uxbox.{{ DOMAIN }}; + server_name _; - # Reverse Proxy to Backend (Avoids XSS concerns) --Update api to be whatever your site uses to access your backend + # Frontend + location / { + root /usr/share/nginx/html/; + + try_files $uri /index.html; + gzip on; + gzip_types text/css text/javascript application/x-javascript application/javascript application/json; + + add_header Cache-Control "max-age=15552000" always; + } + + location /view { + alias /usr/share/nginx/html/view; + } + + # Backend location /api/ { - #proxy_pass http://backend; - proxy_pass http://uxbackend:6060; + # Reverse Proxy to Backend (Avoids XSS concerns) --Update backend to be whatever your site uses to access your backend + proxy_pass http://uxboxbackend; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; @@ -40,15 +56,4 @@ server { # IMPORTANT: Update uxbox.{{ DOMAIN }} to your production site. This will allow cookies to work as expected when using your deployment locally #proxy_cookie_domain localhost uxbox.{{ DOMAIN }}; } - - # Application - location / { - root /usr/share/nginx/html/; - - try_files $uri /index.html; - gzip on; - gzip_types text/css text/javascript application/x-javascript application/javascript application/json; - - add_header Cache-Control "max-age=15552000" always; - } } \ No newline at end of file