From be0355d59b37cc01c637f7168c781fb1b9fada07 Mon Sep 17 00:00:00 2001 From: Gabriel Tan-Chen Date: Wed, 19 Aug 2020 16:28:46 -0400 Subject: [PATCH 01/11] nginx config --- config/nginx.conf.erb | 54 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 config/nginx.conf.erb diff --git a/config/nginx.conf.erb b/config/nginx.conf.erb new file mode 100644 index 0000000..11fba0e --- /dev/null +++ b/config/nginx.conf.erb @@ -0,0 +1,54 @@ +daemon off; +#Heroku dynos have at least 4 cores. +worker_processes <%= ENV['NGINX_WORKERS'] || 4 %>; + +events { + use epoll; + accept_mutex on; + worker_connections <%= ENV['NGINX_WORKER_CONNECTIONS'] || 1024 %>; +} + +http { + gzip on; + gzip_comp_level 2; + gzip_min_length 512; + + server_tokens off; + + log_format l2met 'measure#nginx.service=$request_time request_id=$http_x_request_id'; + access_log <%= ENV['NGINX_ACCESS_LOG_PATH'] || 'logs/nginx/access.log' %> l2met; + error_log <%= ENV['NGINX_ERROR_LOG_PATH'] || 'logs/nginx/error.log' %>; + + include mime.types; + default_type application/octet-stream; + sendfile on; + + #Must read the body in 5 seconds. + client_body_timeout 5; + + upstream app_server { + server unix:/tmp/nginx.socket fail_timeout=0; + } + + server { + listen <%= ENV['PORT'] %>; + server_name _; + keepalive_timeout 5; + + add_header Strict-Transport-Security "max-age=31536000"; + add_header Referrer-Policy "no-referrer, same-origin"; + + location / { + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $http_host; + proxy_redirect off; + proxy_pass http://app_server; + } + + <% if ENV['STATIC_PROXY'] %> + location /static/ { + proxy_pass http://<%= ENV['STATIC_PROXY'] %>/static/; + } + <% end %> + } +} From daeedf40334f27a1138b79334dcbad059afbf980 Mon Sep 17 00:00:00 2001 From: Gabriel Tan-Chen Date: Wed, 19 Aug 2020 16:33:56 -0400 Subject: [PATCH 02/11] pin node version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e5c9df8..288b7b3 100644 --- a/package.json +++ b/package.json @@ -75,6 +75,6 @@ "winston": "^3.2.1" }, "engines": { - "node": "8.* || >= 10.*" + "node": "12.17.0" } } From 209da2fc60a85aaae3dc98bfc789b939121dbe47 Mon Sep 17 00:00:00 2001 From: Gabriel Tan-Chen Date: Wed, 19 Aug 2020 17:40:19 -0400 Subject: [PATCH 03/11] pin npm --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 288b7b3..c9766bc 100644 --- a/package.json +++ b/package.json @@ -75,6 +75,7 @@ "winston": "^3.2.1" }, "engines": { - "node": "12.17.0" + "node": "12.17.0", + "npm": "6.14.4" } } From ed0a2418ab018e80516218c4cb6df3d11c89485f Mon Sep 17 00:00:00 2001 From: Gabriel Tan-Chen Date: Thu, 20 Aug 2020 08:00:47 -0400 Subject: [PATCH 04/11] proxy headers --- config/nginx.conf.erb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/nginx.conf.erb b/config/nginx.conf.erb index 11fba0e..80676af 100644 --- a/config/nginx.conf.erb +++ b/config/nginx.conf.erb @@ -48,6 +48,9 @@ http { <% if ENV['STATIC_PROXY'] %> location /static/ { proxy_pass http://<%= ENV['STATIC_PROXY'] %>/static/; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; } <% end %> } From 33fb3a55c74a858265a54c962c8ccea3934ca630 Mon Sep 17 00:00:00 2001 From: Gabriel Tan-Chen Date: Thu, 20 Aug 2020 08:14:31 -0400 Subject: [PATCH 05/11] update proxy path --- config/nginx.conf.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/nginx.conf.erb b/config/nginx.conf.erb index 80676af..79f92be 100644 --- a/config/nginx.conf.erb +++ b/config/nginx.conf.erb @@ -47,7 +47,7 @@ http { <% if ENV['STATIC_PROXY'] %> location /static/ { - proxy_pass http://<%= ENV['STATIC_PROXY'] %>/static/; + proxy_pass http://<%= ENV['STATIC_PROXY'] %>/; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; From b06909ad6d3b507f236640ff119b8966c63d96ee Mon Sep 17 00:00:00 2001 From: Gabriel Tan-Chen Date: Thu, 20 Aug 2020 09:16:53 -0400 Subject: [PATCH 06/11] update proxy path --- config/nginx.conf.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/nginx.conf.erb b/config/nginx.conf.erb index 79f92be..fd40431 100644 --- a/config/nginx.conf.erb +++ b/config/nginx.conf.erb @@ -47,7 +47,7 @@ http { <% if ENV['STATIC_PROXY'] %> location /static/ { - proxy_pass http://<%= ENV['STATIC_PROXY'] %>/; + proxy_pass http://<%= ENV['STATIC_PROXY'] %>/interactives/2019annualreport/static/; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; From 52a5339b2488fa58e50e9b8505ab122a572959a0 Mon Sep 17 00:00:00 2001 From: Gabriel Tan-Chen Date: Thu, 20 Aug 2020 09:17:33 -0400 Subject: [PATCH 07/11] update location --- config/nginx.conf.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/nginx.conf.erb b/config/nginx.conf.erb index fd40431..cebc686 100644 --- a/config/nginx.conf.erb +++ b/config/nginx.conf.erb @@ -46,7 +46,7 @@ http { } <% if ENV['STATIC_PROXY'] %> - location /static/ { + location /interactives/2019annualreport/static/ { proxy_pass http://<%= ENV['STATIC_PROXY'] %>/interactives/2019annualreport/static/; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; From 7e90aa42450ce8e318b1e66da90bba850e81acf1 Mon Sep 17 00:00:00 2001 From: Gabriel Tan-Chen Date: Thu, 20 Aug 2020 10:23:54 -0400 Subject: [PATCH 08/11] pin winston --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c9766bc..32c9d22 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,7 @@ "sass": "1.22.12", "sass-lint": "1.13.1", "sharp": "0.23.2", - "winston": "^3.2.1" + "winston": "3.2.1" }, "engines": { "node": "12.17.0", From c56e26fcf88fe52d7c681ac5a1d7c4692c8f9eba Mon Sep 17 00:00:00 2001 From: Gabriel Tan-Chen Date: Thu, 20 Aug 2020 10:58:21 -0400 Subject: [PATCH 09/11] add static.json --- static.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 static.json diff --git a/static.json b/static.json new file mode 100644 index 0000000..19075cb --- /dev/null +++ b/static.json @@ -0,0 +1,7 @@ +{ + "proxies": { + "/interactives/2019annualreport/static/": { + "origin": "https://${STATIC_PROXY}/" + } + } +} From b5a85637974dfde15822a92dedba43970fea19cd Mon Sep 17 00:00:00 2001 From: yang-wang-ds Date: Tue, 25 Oct 2022 11:00:57 -0400 Subject: [PATCH 10/11] Upgrading to heroku-22 From 4bd9848b64f0edd53e00f212b398f64402f9a8ab Mon Sep 17 00:00:00 2001 From: yang-wang-ds Date: Tue, 25 Oct 2022 12:25:26 -0400 Subject: [PATCH 11/11] comparing heroku staging to repo