You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "rastiehaiev (via GitHub)" <gi...@apache.org> on 2023/12/19 10:16:07 UTC
[I] feat: As a user, I want to be able to specify scheme on node level, so that I can create upstream with different schemes per route [apisix]
rastiehaiev opened a new issue, #10668:
URL: https://github.com/apache/apisix/issues/10668
### Description
I would like to create an upstream with nodes A, B and C, where A and B would be primary, and C would act as a fallback. There is a [nice instruction](https://github.com/apache/apisix/issues/9703) on how to achieve fallbacks functionality using node priority. However, in my installation nodes A and B are `http`, but node C is `https`.
I can specify scheme only on upstream level and there is no such thing as a fallback upstream in APISIX. Is there any way I can implement fallbacks with such installation?
I was thinking about creation of my own plugin for this, but accessing upstream nodes health in custom plugins is uneasy task. What I'm suggesting is allowing to specify scheme on node level:
```
{
"id": "default-upstream",
"name": "default-upstream",
"desc": "Default upstream",
"type": "roundrobin",
"scheme": "http",
"timeout": {
"connect": 30,
"read": 30,
"send": 10
},
"nodes": [
{
"host": "A",
"port": 8080,
"weight": 0
},
{
"host": "B",
"port": 8080,
"weight": 0
},
{
"host": "C",
"port": 443,
"weight": 0,
"priority": -1,
"scheme": "https"
}
]
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] feat: As a user, I want to be able to specify scheme on node level, so that I can create upstream with different schemes per route [apisix]
Posted by "rastiehaiev (via GitHub)" <gi...@apache.org>.
rastiehaiev commented on issue #10668:
URL: https://github.com/apache/apisix/issues/10668#issuecomment-1864437043
I've managed to workaround this issue by creating a custom plugin that replaces `upstream_scheme` from http to https on `before_proxy` stage:
`http2http-auto-switch.lua`:
```
-- APISIX allows to specify scheme at upstream level.
-- Thus, this is impossible to have both http and https nodes in one upstream.
-- This plugin replaces upstream scheme from http to https if server's port is 443.
-- Plugin is being executed at 'before_proxy' stage when target server is picked for request execution.
local core = require("apisix.core")
local _M = {
version = 0.1,
priority = 7000,
name = "http2https-auto-switch",
schema = {},
}
function _M.before_proxy(_, ctx)
if ctx.picked_server then
if ctx.picked_server.port == 443 and ctx.upstream_scheme ~= "https" then
core.log.warn("Server host: " .. ctx.picked_server.host .. ", port: " .. ctx.picked_server.port .. ", scheme: " .. ctx.upstream_scheme)
core.log.warn("Replacing scheme " .. ctx.upstream_scheme, " with https")
ctx.upstream_scheme = "https"
ctx.var["upstream_scheme"] = ctx.upstream_scheme
end
end
end
return _M
```
Fallback upstream would be nice to have though.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] feat: As a user, I want to be able to specify scheme on node level, so that I can create upstream with different schemes per route [apisix]
Posted by "rastiehaiev (via GitHub)" <gi...@apache.org>.
rastiehaiev commented on issue #10668:
URL: https://github.com/apache/apisix/issues/10668#issuecomment-1862652289
Or, taking into account that for healtcheck we also need to specify scheme, it would be even better to be able to specify fallback upstream for route and service.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] feat: As a user, I want to be able to specify scheme on node level, so that I can create upstream with different schemes per route [apisix]
Posted by "Baoyuantop (via GitHub)" <gi...@apache.org>.
Baoyuantop closed issue #10668: feat: As a user, I want to be able to specify scheme on node level, so that I can create upstream with different schemes per route
URL: https://github.com/apache/apisix/issues/10668
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org