Skip to content
This repository has been archived by the owner on Dec 7, 2020. It is now read-only.

Unable to set the request Host header #259

Closed
slaash opened this issue Aug 2, 2017 · 6 comments
Closed

Unable to set the request Host header #259

slaash opened this issue Aug 2, 2017 · 6 comments

Comments

@slaash
Copy link

slaash commented Aug 2, 2017

Hi,

In our setup the keycloak proxy's upstream-url is set to the internal URL of a web application that is not accessible from the internet (e.g. http://webapp.internal:6543/).
We use an Amazon Load Balancer that forwards requests to the keycloak proxy. It is accessed publicly like https://protected-webapp.example.com.

Our issue is thet the webapp relies on the Host header from the http request for creating URLs, so now we are getting the internal hostname (webapp.internal:6543) in the browser, which of course does not work from the internet.

I see that the Host header is set by the keycloak proxy to the value of upstream-url.
I tried to set the Host header manually like this:
headers:
Host: protected-webapp.example.com
But still it gets to the webapp with the upstream-url value.

Is there any way to set the Host header to a custom value?

Thanks!

@songokudbz
Copy link

songokudbz commented Oct 24, 2017

Hi I've also have kinda the same problem.

I have 2 containers in a Kubernetes POD. One is mapped to PORT 8080 (the actual application) and another container with the keycloak-proxy thing. The thing is if I try to access the internal container with trailing slash ('/'), i.e. <PUBLIC_URL>/applicationContext/, then after the login on keycloak side I am being sent back to the <PUBLIC_URL>/applicationContext/ and everything works. BUT, if I go to the URL without the trailing slash, i.e. <PUBLIC_URL>/applicationContext, then I will be redirected back from Keycloak after a successful login to http://localhost:8080/applicationContext which is not good.

How can I solve this?

@jangaraj
Copy link
Contributor

@songokudbz try to set config redirection-url="<PUBLIC_URL>"

@songokudbz
Copy link

songokudbz commented Oct 24, 2017

@jangaraj it did not do the trick. I've added the redirection-url but it still sends me to localhost. My upstream url looks like this:
upstream-url: "http://localhost:{{ service.ports[0].targetPort }}"
do I need to change it as well to the PUBLIC URL?

@jangaraj
Copy link
Contributor

@songokudbz: No, you don't need to update upstream-url. I think that redirect to the localhost is generated by your app, not by keycloak-proxy -> debug/fix your app code/config.

@pjeby
Copy link
Contributor

pjeby commented Dec 21, 2017

As of 2.1.0, you can now set the Host: header in your headers:.

@gambol99
Copy link
Contributor

gambol99 commented Feb 4, 2018

Closing the issue as it was fixed in v2.1.0

@gambol99 gambol99 closed this as completed Feb 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants