postgrest
postgrest copied to clipboard
`server-host=!6` also binds to ipv4
Problem
We document that !6
should only bind to ipv6, however a request using ipv4 succeeds
$ PGRST_SERVER_HOST='!6' postgrest-with-postgresql-16 postgrest-run
$ curl localhost:3000/projects --ipv4 -I
HTTP/1.1 200 OK
Notes
Using !4
works as expected:
PGRST_SERVER_HOST='!4' postgrest-with-postgresql-15 postgrest-run
$ curl localhost:3000/projects --ipv6 -I
curl: (7) Failed to connect to localhost port 3000 after 0 ms: Connection refused
Did you find out whether this and #3203 are actually bugs on our side or in the lib we are using?
@wolfgangwalther Are you able to reproduce? Not sure if this could be OS-specific.
Did you find out whether this and https://github.com/PostgREST/postgrest/issues/3203 are actually bugs on our side or in the lib we are using?
It must be the lib, we only do this: https://github.com/PostgREST/postgrest/blob/71887e4b78aca74adcdabfc61c2901e7e479878f/src/PostgREST/App.hs#L95
- https://hackage.haskell.org/package/warp-3.4.0/docs/Network-Wai-Handler-Warp.html#v:setHost
- https://hackage.haskell.org/package/warp-3.4.0/docs/Network-Wai-Handler-Warp.html#t:HostPreference
Are you able to reproduce? Not sure if this could be OS-specific.
I did not try to. I was just wondering, because ...
It must be the lib, we only do this:
... that's what I remembered.
So if you can reproduce this with plain warp, then it would probably be better to raise this upstream.
So if you can reproduce this with plain warp, then it would probably be better to raise this upstream.
I'm testing the library right now to confirm this. The "funny" thing is that *
does not seem to accept ipv6
requests.
$ PGRST_SERVER_HOST='*' postgrest-with-postgresql-16 postgrest-run
$ curl localhost:3000/projects --ipv6 -I
curl: (7) Failed to connect to localhost port 3000 after 0 ms: Couldn't connect to server
@laurenceisla That looks the same as https://github.com/PostgREST/postgrest/issues/3203
@steve-chavez True, didn't check that.
Made a gist with the tests I did:
https://gist.github.com/laurenceisla/61af763fb028437f24e5a869225eb1f8
The behavior is the same with Warp only.
I submitted the issue upstream here: https://github.com/yesodweb/wai/issues/976