sish icon indicating copy to clipboard operation
sish copied to clipboard

Pass alias as a header to service

Open benperiton opened this issue 3 years ago • 3 comments

I have a few sites that run locally for development, which I use the host-header=mysite.local.domain.com for, and that works just fine, the only issue is that all the links etc are set as mysite.local.domain.com rather than the alias used.

It would be handy if there was another header passed that said what the alias is. For example:

ssh -R test:443:localhost:443 ssi.sh host-header=mysite.local.domain.com

would also pass through some headers like

X-Sish-Alias: test
X-Sish-Domain: test.ssi.sh

then I could check for the X-Sish-Domain header and adjust the links accordingly.

Is that possible now, or would it be something that maybe could be implemented?

benperiton avatar Oct 10 '22 13:10 benperiton

This is not currently possible with sish, but shouldn't be very difficult to implement if someone is interested!

We'd need to change the forward proxy here: https://github.com/antoniomika/sish/blob/7aecd2d71877cd52e66a9d1f269a02cce538552e/sshmuxer/httphandler.go#L36 to take a Rewriter from here: https://github.com/vulcand/oxy/blob/master/forward/fwd.go#L65 which modifies the request.

You can also use relative links to solve this issue?

antoniomika avatar Oct 10 '22 14:10 antoniomika

Well, I gave it a go and submitted a PR.

Yea, I have a couple of ones that I can't change to be relative - they are generated automatically - but I think with the x-sish-host I can tweak it to work

benperiton avatar Oct 10 '22 16:10 benperiton

Sounds good, I'll take a look in the coming few days! Thanks for the contribution :)

antoniomika avatar Oct 18 '22 15:10 antoniomika