Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't reach a node service through proxy (502 bad gateway) #3647

Open
marcelbusch opened this issue Dec 13, 2023 · 0 comments
Open

can't reach a node service through proxy (502 bad gateway) #3647

marcelbusch opened this issue Dec 13, 2023 · 0 comments
Labels
bug Something aint working right!

Comments

@marcelbusch
Copy link

marcelbusch commented Dec 13, 2023

I've been trying to figure this out for a couply of hours now but I can't get it to work (lando version v3.20.6).

I've got 3 services running, 1 database and 2 node containers, one containing a nuxt frontend (working fine and as expected) and a directus backend which I can't reach from my computer (the 2 node containers can communicate with each other on the expected addresses though). They both have basically the same configuration, which is why I don't really understand why this won't work:

domain: local.host
services:
  appserver:
    type: node:18
    overrides:
      ports:
        - "8058:8058"
  directus:
    type: node:18
    overrides:
      ports:
        - "8059:8059"

proxy:
  appserver:
    - frontend.local.host:8058
  directus:
    - backend.local.host:8059

Trying backend.local.host gives me 'bad gateway' (logs from traefik below) and 0.0.0.0:8059 gives nothing ('connection was reset' in firefox).

traefik logs

heres the log from inside the proxy: 2023-12-13 11:16:24 time="2023-12-13T10:16:24Z" level=debug msg="vulcand/oxy/roundrobin/rr: begin ServeHttp on request" Request="see below" 2023-12-13 11:16:24 time="2023-12-13T10:16:24Z" level=debug msg="vulcand/oxy/roundrobin/rr: Forwarding this request to URL" Request="see below" ForwardURL="http://*.*.*.5:8059" 2023-12-13 11:16:24 time="2023-12-13T10:16:24Z" level=debug msg="'502 Bad Gateway' caused by: dial tcp *.*.*.5:8059: connect: connection refused" 2023-12-13 11:16:24 time="2023-12-13T10:16:24Z" level=debug msg="vulcand/oxy/roundrobin/rr: completed ServeHttp on request" Request="see below"

for better readability I formatted the request json (its always the same obv)

{
"Method": "GET",
"URL": {
"Scheme": "",
"Opaque": "",
"User": null,
"Host": "",
"Path": "/admin",
"RawPath": "",
"ForceQuery": false,
"RawQuery": "",
"Fragment": ""
},
"Proto": "HTTP/1.1",
"ProtoMajor": 1,
"ProtoMinor": 1,
"Header": {
"Accept": [
"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,/;q=0.8"
],
"Accept-Encoding": [
"gzip, deflate"
],
"Accept-Language": [
"en-GB,en;q=0.5"
],
"Connection": [
"keep-alive"
],
"Dnt": [
"1"
],
"Upgrade-Insecure-Requests": [
"1"
],
"User-Agent": [
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:120.0) Gecko/20100101 Firefox/120.0"
],
"X-Forwarded-Host": [
"backend.local.host"
],
"X-Forwarded-Port": [
"80"
],
"X-Forwarded-Proto": [
"http"
],
"X-Forwarded-Server": [
"fad63424176a"
],
"X-Lando": [
"on"
],
"X-Real-Ip": [
"...1"
]
},
"ContentLength": 0,
"TransferEncoding": null,
"Host": "backend.local.host",
"Form": null,
"PostForm": null,
"MultipartForm": null,
"Trailer": null,
"RemoteAddr": "
...1:55248",
"RequestURI": "/admin",
"TLS": null
}

I however reach the frontend app (running on 0.0.0.0:8058) without any problem, through 0.0.0.0:8058 and through frontend.local.host.

traefik logs for successfull request

2023-12-13 11:27:22 time="2023-12-13T10:27:22Z" level=debug msg="vulcand/oxy/roundrobin/rr: begin ServeHttp on request" Request="see below"
2023-12-13 11:27:22 time="2023-12-13T10:27:22Z" level=debug msg="vulcand/oxy/roundrobin/rr: Forwarding this request to URL" ForwardURL="http://..*.4:8058" Request="see below"
2023-12-13 11:27:22 time="2023-12-13T10:27:22Z" level=debug msg="vulcand/oxy/roundrobin/rr: completed ServeHttp on request" Request="see below"

and again the request json:

{
"Method": "GET",
"URL": {
"Scheme": "",
"Opaque": "",
"User": null,
"Host": "",
"Path": "/",
"RawPath": "",
"ForceQuery": false,
"RawQuery": "",
"Fragment": ""
},
"Proto": "HTTP/1.1",
"ProtoMajor": 1,
"ProtoMinor": 1,
"Header": {
"Accept": [
"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,/;q=0.8"
],
"Accept-Encoding": [
"gzip, deflate"
],
"Accept-Language": [
"en-GB,en;q=0.5"
],
"Connection": [
"keep-alive"
],
"Dnt": [
"1"
],
"Upgrade-Insecure-Requests": [
"1"
],
"User-Agent": [
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:120.0) Gecko/20100101 Firefox/120.0"
],
"X-Forwarded-Host": [
"frontend.local.host"
],
"X-Forwarded-Port": [
"80"
],
"X-Forwarded-Proto": [
"http"
],
"X-Forwarded-Server": [
"fad63424176a"
],
"X-Lando": [
"on"
],
"X-Real-Ip": [
"...1"
]
},
"ContentLength": 0,
"TransferEncoding": null,
"Host": "frontend.local.host",
"Form": null,
"PostForm": null,
"MultipartForm": null,
"Trailer": null,
"RemoteAddr": "
...1:38154",
"RequestURI": "/",
"TLS": null
}

When I ssh into the directus container and run curl http://0.0.0.0:8059/admin I get a normal response, running the same from outside gives curl: (52) Empty reply from server.

I don't have a real understanding of how traefik or proxying in general works, so if it is quite obvious why this is happening I am sorry. Or is this an issue with directus?

@marcelbusch marcelbusch added the bug Something aint working right! label Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something aint working right!
Projects
None yet
Development

No branches or pull requests

1 participant