Router: Origin client IP is lost if behind a proxy
[provide a description of the issue]
Version
3.6.0
Steps To Reproduce
- Create a simple server and log the X-Forwarded-For
- Deploy in openshift
- Make a request
Current Result
If client is behind a proxy the ip of this proxy is provided
Expected Result
If we look at the documentation of X-Forwarded-For the format could be:
X-Forwarded-For: client, proxy1, proxy2
Additional Information
any sample config. it will help to debug.
Hello
I did not deployed any custom rooter so I suppose I am using the default rooter template coming with default openshift installation with ansible (1 master, 1 node infra and 1 node for application)
One solution to this is to enable Proxy Protocol on the proxy you're using (We're using ELB) and the OpenShift haproxy. If you're using SSL the route will need to be configured to re-encrypt so that it can inject the header. Example setup below:
Add Proxy Protocol policy to ELB
aws elb create-load-balancer-policy --load-balancer-name {{elb_name}} --policy-name ProxyProtocol-policy --policy-type-name ProxyProtocolPolicyType --policy-attributes AttributeName=ProxyProtocol,AttributeValue=true
Enable Policy
aws elb set-load-balancer-policies-for-backend-server --load-balancer-name {{elb_name}} --instance-port 80 --policy-names ProxyProtocol-policy
aws elb set-load-balancer-policies-for-backend-server --load-balancer-name {{elb_name}} --instance-port 443 --policy-names ProxyProtocol-policy
Configure haproxy
oc env dc/router ROUTER_USE_PROXY_PROTOCOL=true
This will send the Forwarded header, which will look like this on the pod:
Forwarded: for=10.11.12.83;host=www.example.com;proto=https
OK thanks I will have a look.
Hello,
Openshift Origin : v1.4.1 2 ELB: Infra and app, Infra routes are all internal resources like monitoring etc. App is used for our customer exposed routes.
I tried the same as above and see that the routes stop working once I enable proxy protocol on both the ELB and Router on openshift.
Could you let me know the logs to look for and possibly what could be causing the issue. This was working few days back but with another issue with only HTTP routes not working, but this time around the moment I enable proxy protocol I'm not able to access either the Openshift console or any of the defined routes.
By working earlier I mean, that we keep doing nightly builds and this same was working atleast with the HTTPS routes in the earlier case, but now apparently it brings down the entire enviornment, unless I go back and disable proxy protocol on our Infra ELB.
Thanks in advance and appreciate your efforts in helping me with this.
Thanks, Sreekanth
I also meet the a same problem . My router is openshift/origin-haproxy-router:v1.4.1, with environment variable ROUTER_USE_PROXY_PROTOCOL set to true and the haproxy before router configured to send-proxy, it doesn't work. Request to router via the haproxy failed with 400.
I check the conf file in router, no 'accept-proxy' set after the bind :443 and bind:80, I add 'accept-proxy' to the haproxy-config.template and build a new image according to https://docs.openshift.org/latest/install_config/router/customized_haproxy_router.html. When the new router run, it always fails to do healthy check to port 1936.
Are there any guys meet this situation?
Thanks in advance
My issue is resolved according to https://docs.openshift.org/1.4/install_config/router/customized_haproxy_router.html#using-configmap-replace-template
@Lazast: Could you please elaborate on the modifications you did to the template to get this working, My apologies as I wasn't too sure of what has been changed in the template.
Appreciate your help on this.
Thanks, Sreekanth
@sreekanth-ragi Get the template file from origin haproxy-router(v1.4.1), add "accept-proxy" after bind :{{env "ROUTER_SERVICE_HTTPS_PORT" "443"}} and bind :{{env "ROUTER_SERVICE_HTTP_PORT" "80"}} directly.
Issues go stale after 90d of inactivity.
Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.
If this issue is safe to close now please do so with /close.
/lifecycle stale
Yeah, 1.4 is too early for the proxy protocol support. I'd encourage you to upgrade to a later version.