Use the environment variable directly
This commit is contained in:
1 parent
0919b03143
commit
f7d3367a9f
1 file changed
+10
-9
@@ -11,18 +11,19 @@ server {
|
||||
# Server domain name
|
||||
server_name _;
|
||||
|
||||
set_by_lua_block $pot_url_scheme {
|
||||
local haystack = os.getenv('YT_POT_BGUTIL_BASE_URL') or ''
|
||||
local needle = 'https://'
|
||||
local scheme = 'http'
|
||||
if haystack:sub(1, #needle) == needle then
|
||||
scheme = 'https'
|
||||
set_by_lua_block $pot_url {
|
||||
local default = 'http://token_server'
|
||||
local url = os.getenv('YT_POT_BGUTIL_BASE_URL')
|
||||
if not url then
|
||||
return default
|
||||
end
|
||||
return scheme
|
||||
if #url and url:find('://') then
|
||||
return url
|
||||
end
|
||||
return default
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_pass $pot_url_scheme://token_server;
|
||||
proxy_redirect default;
|
||||
proxy_pass $pot_url;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user