diff --git a/config/nginx.conf.erb b/config/nginx.conf.erb index 1067911f9f4..3435fc6dc4a 100644 --- a/config/nginx.conf.erb +++ b/config/nginx.conf.erb @@ -107,7 +107,7 @@ http { upstream app_server { server localhost:8888 fail_timeout=0; - } + } server { listen <%= ENV["PORT"] %>; @@ -130,15 +130,33 @@ http { rewrite ^ https://$host$request_uri? permanent; } - location / { - proxy_pass http://app_server; - } - - <% if ENV['USE_FASTBOOT'] %> - # Just in case, only forward "/policies" to Ember for a moment - location = /policies { - proxy_pass http://localhost:9000; - } + <% if ENV['USE_FASTBOOT'] == "staging-experimental" %> + # Experimentally send all non-backend requests to FastBoot + + location /api/ { + proxy_pass http://app_server; + } + + # FastBoot + location / { + proxy_pass http://localhost:9000; + } + <% elsif ['USE_FASTBOOT'] %> + # Fastboot is enabled only for allowed paths + + location = /policies { + proxy_pass http://localhost:9000; + } + + location / { + proxy_pass http://app_server; + } + <% else %> + # FastBoot is disabled, backend sends the static Ember index HTML for non-backend paths + + location / { + proxy_pass http://app_server; + } <% end %> location ~ ^/api/v./crates/new$ { diff --git a/script/start-web.sh b/script/start-web.sh index 47317d0867c..dce52263cd1 100755 --- a/script/start-web.sh +++ b/script/start-web.sh @@ -1,12 +1,12 @@ #! /bin/bash set -ue -if [[ "${USE_FASTBOOT:-0}" = 1 ]]; then - export USE_FASTBOOT=1 +if [[ -z "${USE_FASTBOOT}" ]]; then + unset USE_FASTBOOT + bin/start-nginx ./target/release/server +else + export USE_FASTBOOT node --optimize_for_size --max_old_space_size=200 fastboot.js & bin/start-nginx ./target/release/server & wait -n -else - unset USE_FASTBOOT - bin/start-nginx ./target/release/server fi