Comments (12)
What happens if client --> k8s --> pod[backend]
?
The error message seems from backend?
from easegress.
What happens if
client --> k8s --> pod[backend]
? The error message seems from backend?
client --> k8s --> pod[backend]
works well.
from easegress.
Hi, if client --> k8s --> pod[backend]
works and client --> easegress --> backend
works.
It seems some network problem from easegress to k8s?
But websocketproxy
can find the backend and got a status code of 404 (not like a network problem).
Emmm, I guess we can use some tool like wireshark to catch some packets. To see what's the difference between easegresss -> k8s
and client -> k8s
. If they send the same packet, they should get same result.
Make sure you client is on same server of easegress. You can add this filter to your pipeline to diff the requests from your client and easegress.
kind: RequestAdaptor
name: request-adaptor
header:
add:
X-Easegress: Test
If they send different packets, we can find the problem of easegress.
For the information you have provided, I can't dig more...
from easegress.
Which way does Easegress access K8s? Ingress with node port or cluster IP? In my initial intuition there could be a problem in k8s service-level.
from easegress.
Which way does Easegress access K8s? Ingress with node port or cluster IP? In my initial intuition there could be a problem in k8s service-level.
We use node port. Before we use apisix works well .
from easegress.
Hi, if
client --> k8s --> pod[backend]
works andclient --> easegress --> backend
works. It seems some network problem from easegress to k8s? Butwebsocketproxy
can find the backend and got a status code of 404 (not like a network problem).Emmm, I guess we can use some tool like wireshark to catch some packets. To see what's the difference between
easegresss -> k8s
andclient -> k8s
. If they send the same packet, they should get same result.Make sure you client is on same server of easegress. You can add this filter to your pipeline to diff the requests from your client and easegress.
kind: RequestAdaptor name: request-adaptor header: add: X-Easegress: Test
If they send different packets, we can find the problem of easegress.
For the information you have provided, I can't dig more...
I may have identified the issue. When Easegress accesses my k8s cluster, the Ingress fails to retrieve the Host. Consequently, it becomes unable to locale the appropriate service.
I have come across the "x-forwarded-host" header in the program. However, I am unsure about how to utilize it.
from easegress.
In easegress websocket proxy, if X-Forwarded-Host is empty, then is will be the host of request.
const xForwardedHost = "X-Forwarded-Host"
xfh := req.HTTPHeader().Get(xForwardedHost)
if xfh == "" && req.Host() != "" {
opts.HTTPHeader.Set(xForwardedHost, req.Host())
}
from easegress.
What approach should I take on my Kubernetes (K8s) side to address this issue?
I have make a test.
client --> easegress --> local nginx --> backend
In the case of a WebSocket request, the host information cannot be obtained on the local Nginx server.
from easegress.
opts.Host = req.Host() // add this line for reverse proxy
const xForwardedHost = "X-Forwarded-Host"
xfh := req.HTTPHeader().Get(xForwardedHost)
if xfh == "" && req.Host() != "" {
opts.HTTPHeader.Set(xForwardedHost, req.Host())
}
After adding this line, the functionality was restored successfully.
from easegress.
https://github.com/megaease/easegress/blob/main/pkg/filters/proxies/server.go#L32
// Server is a backend proxy server.
type Server struct {
URL string `json:"url" jsonschema:"required,format=url"`
Tags []string `json:"tags,omitempty" jsonschema:"uniqueItems=true"`
Weight int `json:"weight,omitempty" jsonschema:"minimum=0,maximum=100"`
KeepHost bool `json:"keepHost,omitempty" jsonschema:"default=false"`
AddrIsHostName bool `json:"-"`
Unhealth bool `json:"-"`
// HealthCounter is used to count the number of successive health checks
// result, positive for healthy, negative for unhealthy
HealthCounter int `json:"-"`
}
The KeepHost
property is not utilized in the Websocket proxy. I believe we can incorporate it into the Websocket DialOptions struct, similar to HTTP proxy.
https://github.com/megaease/easegress/blob/main/pkg/filters/proxies/httpproxy/wspool.go#L121
opts := &websocket.DialOptions{
HTTPHeader: req.HTTPHeader().Clone(),
CompressionMode: websocket.CompressionDisabled,
}
// only set host when server address is not host name OR
// server is explicitly told to keep the host of the request.
if !svr.AddrIsHostName || svr.KeepHost {
opts.Host = req.Host()
}
opts.HTTPHeader.Del("Sec-WebSocket-Origin")
opts.HTTPHeader.Del("Sec-WebSocket-Protocol")
opts.HTTPHeader.Del("Sec-WebSocket-Accept")
opts.HTTPHeader.Del("Sec-WebSocket-Extensions")
Now, it works for me.
from easegress.
In the implementation of websocket pkg, it said the host may overrides the host of http. i think that maybe the problem.
// Host optionally overrides the Host HTTP header to send. If empty, the value
// of URL.Host will be used.
Host string
from easegress.
Hi, @cyrnicolase , your solution seems great and consistency with Proxy
filter. Could you please make a pr about it? Thanks!
from easegress.
Related Issues (20)
- [Question]: how does the sidecar (mesh worker role) intercept outbound traffic HOT 7
- An option for enabling periodic health checks of the servers in Proxy plugin HOT 2
- Strict yaml schema validation via openAPIV3Schema HOT 1
- [Question]: Is there command `egctl convert ` ? HOT 2
- [Question]: egctl apply error HOT 2
- [Question]: New filter run panic HOT 8
- Filter logger optimize HOT 5
- [Bug]: easegress-server --signal-upgrade=true panic HOT 2
- [Question]:Is buildOutputResponse missing ? HOT 4
- Filter will be created even it is not referenced in flow HOT 3
- Adding url decoding function to extend template functionality in easegress builder filters HOT 5
- [Question]: Why does pipeline not map properly to the backend server? HOT 3
- [Question]: Pipeline HandleWithBeforeAfter not work well HOT 23
- [Question]: Is there something wrong with the example in this IngressController doc? HOT 1
- [Question]: Why does my IngressController experiment not work? HOT 17
- [Question]: When using Easegress images version V2.6.1 and above, the IngressController does not function properly. HOT 5
- [Question]: When using Easegress as an Ingress controller, how can I add a global filter to the default HTTP server? HOT 8
- [Question]: Websocket log expected error HOT 3
- Report the use of components with vulnerabilities in easegress HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from easegress.