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

[Feature] Rewrite Host header #174

Open
axelkar opened this issue Aug 10, 2024 · 3 comments
Open

[Feature] Rewrite Host header #174

axelkar opened this issue Aug 10, 2024 · 3 comments

Comments

@axelkar
Copy link

axelkar commented Aug 10, 2024

This is useful when reverse proxying another vhosted reverse proxy. Also example.com doesn't work with Host: localhost:8080

@junkurihara
Copy link
Owner

junkurihara commented Aug 10, 2024

Hi @axelkar

As you mentioned, rpxy does not overwrite HOST value with upstream hostname (like 192.168.xx.x seen from rpxy) by default. (This can be explicitly specified by keep_original_host).

But by setting set_upstream_host, rpxy overwrites HOST value with upstream hostname (like www.yahoo.com specified in location directive). Doesn't this meet the requirement in your environment?

Note: keep_original_host is prior to set_upstream_host if both are specified.

@axelkar
Copy link
Author

axelkar commented Aug 10, 2024

I didn't notice the set_upstream_host option! It fixes the problem for now, but I still think setting a custom Host header will be useful.

@xkr47
Copy link
Contributor

xkr47 commented Oct 27, 2024

To make it easier to understand how it would work together with TLS upstreams, would it be better to adopt curl's approach to this (manpage quoted below) and have a connect_to setting on the upstream? Then it would hopefully be clearer that the location setting would always control both the SNI and the Host header, while the connect_to could be used to give a hostname/ip address (and possibly port) to actually connect to. WDYT?

(below, host1[:port1] would be taken from location and host2[:port2] from connect_to)

  --connect-to <HOST1:PORT1:HOST2:PORT2>

         For a request to the given HOST1:PORT1 pair, connect to HOST2:PORT2 instead.  This option  is  suitable
         to  direct requests at a specific server, e.g. at a specific cluster node in a cluster of servers. This
         option is only used to establish the network connection. It does NOT affect the hostname/port  that  is
         used  for  TLS/SSL  (e.g.  SNI, certificate verification) or for the application protocols. "HOST1" and
         "PORT1" may be the empty string, meaning "any host/port". "HOST2" and "PORT2" may  also  be  the  empty
         string, meaning "use the request's original host/port".

         A  "host"  specified  to this option is compared as a string, so it needs to match the name used in re‐
         quest URL. It can be either numerical such as "127.0.0.1" or the full host name such as "example.org".

         This option can be used many times to add many connect rules.

         See also --resolve and -H, --header. Added in 7.49.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants