Skip to content

Commit

Permalink
feat: 转发请求到容器化网关时带上token #8725
Browse files Browse the repository at this point in the history
  • Loading branch information
stubenhuang committed Apr 24, 2023
1 parent eabf718 commit bff9087
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/gateway/core/backend.conf
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ location ~ /(ms/|)([\w-_]+)/api/service/(.*) {
set $service $2;
set $path $3;
set $target '';
set $devops_token '';

proxy_set_header X-DEVOPS-TOKEN $devops_token;

access_by_lua_file 'conf/lua/router_srv.lua';

# 设置proxy header的变量
Expand Down
3 changes: 3 additions & 0 deletions src/gateway/core/lua/util/loadbalance_util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ function _M:getTarget(devops_tag, service_name, cache_tail, ns_config)

-- 转发到容器环境里
if not in_container and string.find(devops_tag, '^kubernetes-') then
if config.gw_token ~= nil and ngx.var.devops_token == '' then
ngx.var.devops_token = config.gw_token
end
local kubernetes_domain = nil
if gateway_project == 'codecc' then
kubernetes_domain = config.kubernetes.codecc.domain
Expand Down

0 comments on commit bff9087

Please sign in to comment.