use ngx.var.scheme instead of https

This commit is contained in:
Karol Wypchlo 2022-02-16 15:09:33 +01:00
parent f7f03d183a
commit 8a536cf43c
No known key found for this signature in database
GPG Key ID: B515DE9EEBE241E1
4 changed files with 12 additions and 12 deletions

View File

@ -81,8 +81,8 @@ proxy_pass https://127.0.0.1/$skylink$path$is_args$args;
# in case siad returns location header, we need to replace the skylink with the domain name # in case siad returns location header, we need to replace the skylink with the domain name
header_filter_by_lua_block { header_filter_by_lua_block {
ngx.header["Skynet-Portal-Api"] = "https://" .. os.getenv("PORTAL_DOMAIN") ngx.header["Skynet-Portal-Api"] = ngx.var.scheme .. "://" .. os.getenv("PORTAL_DOMAIN")
ngx.header["Skynet-Server-Api"] = "https://" .. os.getenv("SERVER_DOMAIN") ngx.header["Skynet-Server-Api"] = ngx.var.scheme .. "://" .. os.getenv("SERVER_DOMAIN")
if ngx.header.location then if ngx.header.location then
-- match location redirect part after the skylink -- match location redirect part after the skylink

View File

@ -82,8 +82,8 @@ access_by_lua_block {
} }
header_filter_by_lua_block { header_filter_by_lua_block {
ngx.header["Skynet-Portal-Api"] = "https://" .. os.getenv("PORTAL_DOMAIN") ngx.header["Skynet-Portal-Api"] = ngx.var.scheme .. "://" .. os.getenv("PORTAL_DOMAIN")
ngx.header["Skynet-Server-Api"] = "https://" .. os.getenv("SERVER_DOMAIN") ngx.header["Skynet-Server-Api"] = ngx.var.scheme .. "://" .. os.getenv("SERVER_DOMAIN")
-- not empty skynet_proof means this is a skylink v2 request -- not empty skynet_proof means this is a skylink v2 request
-- so we should replace the Skynet-Proof header with the one -- so we should replace the Skynet-Proof header with the one

View File

@ -276,8 +276,8 @@ location /skynet/tus {
# extract skylink from base64 encoded upload metadata and assign to a proper header # extract skylink from base64 encoded upload metadata and assign to a proper header
header_filter_by_lua_block { header_filter_by_lua_block {
ngx.header["Skynet-Portal-Api"] = "https://" .. os.getenv("PORTAL_DOMAIN") ngx.header["Skynet-Portal-Api"] = ngx.var.scheme .. "://" .. os.getenv("PORTAL_DOMAIN")
ngx.header["Skynet-Server-Api"] = "https://" .. os.getenv("SERVER_DOMAIN") ngx.header["Skynet-Server-Api"] = ngx.var.scheme .. "://" .. os.getenv("SERVER_DOMAIN")
if ngx.header["Upload-Metadata"] then if ngx.header["Upload-Metadata"] then
local encodedSkylink = string.match(ngx.header["Upload-Metadata"], "Skylink ([^,?]+)") local encodedSkylink = string.match(ngx.header["Upload-Metadata"], "Skylink ([^,?]+)")
@ -311,8 +311,8 @@ location /skynet/metadata {
include /etc/nginx/conf.d/include/portal-access-check; include /etc/nginx/conf.d/include/portal-access-check;
header_filter_by_lua_block { header_filter_by_lua_block {
ngx.header["Skynet-Portal-Api"] = "https://" .. os.getenv("PORTAL_DOMAIN") ngx.header["Skynet-Portal-Api"] = ngx.var.scheme .. "://" .. os.getenv("PORTAL_DOMAIN")
ngx.header["Skynet-Server-Api"] = "https://" .. os.getenv("SERVER_DOMAIN") ngx.header["Skynet-Server-Api"] = ngx.var.scheme .. "://" .. os.getenv("SERVER_DOMAIN")
} }
proxy_set_header User-Agent: Sia-Agent; proxy_set_header User-Agent: Sia-Agent;
@ -324,8 +324,8 @@ location /skynet/resolve {
include /etc/nginx/conf.d/include/portal-access-check; include /etc/nginx/conf.d/include/portal-access-check;
header_filter_by_lua_block { header_filter_by_lua_block {
ngx.header["Skynet-Portal-Api"] = "https://" .. os.getenv("PORTAL_DOMAIN") ngx.header["Skynet-Portal-Api"] = ngx.var.scheme .. "://" .. os.getenv("PORTAL_DOMAIN")
ngx.header["Skynet-Server-Api"] = "https://" .. os.getenv("SERVER_DOMAIN") ngx.header["Skynet-Server-Api"] = ngx.var.scheme .. "://" .. os.getenv("SERVER_DOMAIN")
} }
proxy_set_header User-Agent: Sia-Agent; proxy_set_header User-Agent: Sia-Agent;

View File

@ -95,8 +95,8 @@ http {
# include skynet-portal-api and skynet-server-api header on every request # include skynet-portal-api and skynet-server-api header on every request
header_filter_by_lua_block { header_filter_by_lua_block {
ngx.header["Skynet-Portal-Api"] = "https://" .. os.getenv("PORTAL_DOMAIN") ngx.header["Skynet-Portal-Api"] = ngx.var.scheme .. "://" .. os.getenv("PORTAL_DOMAIN")
ngx.header["Skynet-Server-Api"] = "https://" .. os.getenv("SERVER_DOMAIN") ngx.header["Skynet-Server-Api"] = ngx.var.scheme .. "://" .. os.getenv("SERVER_DOMAIN")
} }
# ratelimit specified IPs # ratelimit specified IPs