Skip to content
New issue

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

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

Already on GitHub? # to your account

iroh-net does not send the Host: header to the relay #2870

Closed
link2xt opened this issue Oct 31, 2024 · 1 comment · Fixed by #2881
Closed

iroh-net does not send the Host: header to the relay #2870

link2xt opened this issue Oct 31, 2024 · 1 comment · Fixed by #2881
Milestone

Comments

@link2xt
Copy link
Contributor

link2xt commented Oct 31, 2024

I am trying to put iroh-relay behind nginx: chatmail/server#445
Current problem is that nginx rejects the requests from iroh-net 0.25.0 with error 400.
According to the logs nginx gets GET /relay HTTP/1.1, then header upgrade: iroh derp http, then rejects because client sent HTTP/1.1 request without "Host" header.
I cannot make it proxy the request to iroh-relay.

HTTP/1.1 requires the Host: header and it seems to be impossible to make nginx proxy requests that don't have one.

I will try to upgrade iroh-net and see if it resolves the problem. EDIT: upgraded to 0.26.0 so far, and the problem remained. Trying to upgrade to 0.27.0, but it has its own problems: deltachat/deltachat-core-rust#6133

@link2xt
Copy link
Contributor Author

link2xt commented Oct 31, 2024

It seems this part of code missies .header(HOST, ...):

let req = Request::builder()
.uri(RELAY_PATH)
.header(UPGRADE, Protocol::Relay.upgrade_header())
.body(http_body_util::Empty::<hyper::body::Bytes>::new())?;

The value should be self.url.host_str().

As described in https://docs.rs/hyper/1.5.0/hyper/header/constant.HOST.html "A Host header field must be sent in all HTTP/1.1 request messages. A 400 (Bad Request) status code will be sent to any HTTP/1.1 request message that lacks a Host header field or contains more than one.".

@link2xt link2xt changed the title iroh-net does not send the Host: header to the relay? iroh-net does not send the Host: header to the relay Oct 31, 2024
@dignifiedquire dignifiedquire added this to the v0.28.0 milestone Nov 1, 2024
github-merge-queue bot pushed a commit that referenced this issue Nov 4, 2024
## Description

Reverse proxies that map multiple virtual hosts need some help to know
where to forward requests to.
That's what the [`HOST`
header](https://datatracker.ietf.org/doc/html/rfc2616#section-14.23) is
for, and it's mandatory for HTTP/1.1 requests.

Closes #2870 

## Change checklist

- [x] Self-review.
- ~~[ ] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.~~
- [x] Tests if relevant.
- ~~[ ] All breaking changes documented.~~
@github-project-automation github-project-automation bot moved this to ✅ Done in iroh Nov 4, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants