From 69940ffc279890b68a3271e3e206eed0d79d3d63 Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Thu, 18 Feb 2021 10:10:04 +0100 Subject: [PATCH 1/2] add skynet-portal-api header --- docker/nginx/conf.d/include/cors | 2 +- docker/nginx/nginx.conf | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docker/nginx/conf.d/include/cors b/docker/nginx/conf.d/include/cors index add176d2..fd8e1220 100644 --- a/docker/nginx/conf.d/include/cors +++ b/docker/nginx/conf.d/include/cors @@ -11,4 +11,4 @@ if ($request_method = 'OPTIONS') { more_set_headers 'Access-Control-Allow-Origin: *'; more_set_headers 'Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE'; more_set_headers 'Access-Control-Allow-Headers: DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range'; -more_set_headers 'Access-Control-Expose-Headers: Content-Length,Content-Range,Skynet-File-Metadata,Skynet-Skylink'; +more_set_headers 'Access-Control-Expose-Headers: Content-Length,Content-Range,Skynet-File-Metadata,Skynet-Skylink,Skynet-Portal-Api'; diff --git a/docker/nginx/nginx.conf b/docker/nginx/nginx.conf index 4cff1f70..3a5b885e 100644 --- a/docker/nginx/nginx.conf +++ b/docker/nginx/nginx.conf @@ -25,6 +25,7 @@ worker_processes 1; #pid logs/nginx.pid; +env SKYNET_PORTAL_API; # declare env variable to use it in config events { worker_connections 1024; @@ -62,5 +63,8 @@ http { #gzip on; + # include skynet-portal-api header on every request + header_filter_by_lua 'ngx.header["Skynet-Portal-Api"] = os.getenv("SKYNET_PORTAL_API")'; + include /etc/nginx/conf.d/*.conf; } From 9853e6e197f4a22773094f997c215ac17b7c4bd6 Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Thu, 18 Feb 2021 10:43:20 +0100 Subject: [PATCH 2/2] include SKYNET_PORTAL_API in setup script --- setup-scripts/setup-docker-services.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup-scripts/setup-docker-services.sh b/setup-scripts/setup-docker-services.sh index fbe063f9..c9aecebd 100755 --- a/setup-scripts/setup-docker-services.sh +++ b/setup-scripts/setup-docker-services.sh @@ -22,6 +22,7 @@ docker-compose --version # sanity check # Create dummy .env file for docker-compose usage with variables # * DOMAIN_NAME - the domain name your server is using ie. example.com +# * SKYNET_PORTAL_API - absolute url to the portal api ie. https://example.com # * EMAIL_ADDRESS - this is the administrator contact email you need to supply for communication regarding SSL certification # * HSD_API_KEY - this is auto generated secure key for your handshake service integration # * CLOUDFLARE_AUTH_TOKEN` - (optional) if using cloudflare as dns loadbalancer (need to change it in Caddyfile too) @@ -32,7 +33,7 @@ docker-compose --version # sanity check # * DISCORD_BOT_TOKEN - required by the discord bot if ! [ -f /home/user/skynet-webportal/.env ]; then HSD_API_KEY=$(openssl rand -base64 32) # generate safe random key for handshake - printf "DOMAIN_NAME=example.com\nEMAIL_ADDRESS=email@example.com\nSIA_WALLET_PASSWORD=\nHSD_API_KEY=${HSD_API_KEY}\nCLOUDFLARE_AUTH_TOKEN=\nAWS_ACCESS_KEY_ID=\nAWS_SECRET_ACCESS_KEY=\nPORTAL_NAME=\nDISCORD_BOT_TOKEN=\n" > /home/user/skynet-webportal/.env + printf "DOMAIN_NAME=example.com\nSKYNET_PORTAL_API=https://example.com\nEMAIL_ADDRESS=email@example.com\nSIA_WALLET_PASSWORD=\nHSD_API_KEY=${HSD_API_KEY}\nCLOUDFLARE_AUTH_TOKEN=\nAWS_ACCESS_KEY_ID=\nAWS_SECRET_ACCESS_KEY=\nPORTAL_NAME=\nDISCORD_BOT_TOKEN=\n" > /home/user/skynet-webportal/.env fi # Start docker container with nginx and client