Jump to content
Welcome to our new Citrix community!

possible to change request hostheader to backend


Recommended Posts

Hi

I have a backend web server that listen to specific hostheader, but I need to give access to the site on another URL.

So can I change the "request hostheader" value when talking to the backend servers?

backend = www.mysite.com

testwww.mysite.com -> NetScaler -> change testwww.mysite.com to www.mysite.com -> backend

Thanks

Edited by: fnielse112 on Jun 22, 2011 8:57 AM

Link to comment
Share on other sites

URL Transformation works on HTTP body. In your case you are changing an HTTP header.

add rewrite action Remove_testwww.mysite.com delete_http_header Host
add rewrite action Add_www.mysite.com insert_http_header Host "\"www.mysite.com\""

add rewrite policy Remove_testwww.mysite.com_P "http.REQ.HEADER(\"host\").EQ(\"testwww.mysite.com\")" Remove_testwww.mysite.com
add rewrite policy Add_www.mysite.com_P true Add_www.mysite.com

Then you bind both policies to your Vserver and give Remove_testwww.mysite.com_P a numerically lower value, so it is used for first.

  • Like 2
Link to comment
Share on other sites

  • 5 years later...

I know it's a really old topic, but I just run in to this issue also.

 

The idea roughly would be to accomplish this:

  1. User browses to https://service.provider.com address which is on a NetScaler Content Switching vServer
  2. The CS then directs this package to the appropriate LB which has either a service or a service group (only one server) which is actually an external service https://example.saasservice.com

The tricky part here is that the backend service is using a similar technology as NS CS to identify the requested host name (multiple services on same IP address). Currently the NetScaler send the package with host = service.provider.com and the backend service doesn’t identify this. Therefore, there’s a need to rewrite the host information for the backend request before it’s sent out and also probably do the same in reverse when the response is received. As long as the NetScaler offloads the traffic this should be doable?

Link to comment
Share on other sites

  • 1 month later...

Hi,

 

basically I have the same issue as Kari with the difference that I need to use not one but two services and I was wondering if it was possible to implement.

 

A user browses to https://loadbalancer.corp.local which would be a NetScaler Load Balancer.

 

Two services are bound to the LB vserver (service-a.corp.local and service-b.corp.local) which both need their own correct HTTP host header to accept a request.

 

So I created two rewrite policies according to Chris post to remove the HTTP host header "loadbalancer.corp.local" and to add a new one which is working fine as long as I use only one service.

 

Is it possible to set the new host header dynamically? If a request hits the LB and it chooses service-a to set "serivce-a.corp.local" as the new host header and if service-b is chosen to set "service-b.corp.local"?

 

To contribute something I added a little asp-script I found which displays all HTTP headers - very useful for troubleshooting, imho.

 

Thanks.

display_http_headers.asp

Link to comment
Share on other sites

  • 11 months later...
On 25.3.2017 at 4:12 AM, Marcus Mietner said:

Hi,

 

basically I have the same issue as Kari with the difference that I need to use not one but two services and I was wondering if it was possible to implement.

 

A user browses to https://loadbalancer.corp.local which would be a NetScaler Load Balancer.

 

Two services are bound to the LB vserver (service-a.corp.local and service-b.corp.local) which both need their own correct HTTP host header to accept a request.

 

So I created two rewrite policies according to Chris post to remove the HTTP host header "loadbalancer.corp.local" and to add a new one which is working fine as long as I use only one service.

 

Is it possible to set the new host header dynamically? If a request hits the LB and it chooses service-a to set "serivce-a.corp.local" as the new host header and if service-b is chosen to set "service-b.corp.local"?

 

To contribute something I added a little asp-script I found which displays all HTTP headers - very useful for troubleshooting, imho.

 

Thanks.

display_http_headers.asp

Hi,
I would also need such an implementation. Have you found a good solution for this topic?

 

Kind Regards,

Chris

Link to comment
Share on other sites

  • 4 weeks later...

Hi Chris,


sorry for my late answer - account problems.


Unfortunately I was only able to implement a workaround.


1. I configured a LB VIP with a rewrite policy to alter the HTTP host header to the FQDN of service-a. Then I bound service-a to the VIP.

2. I repeated step one for service-b but created the second VIP as non-adressable (optional).

3. Then I added the second LB as backup virtual server (protection feature) to the first LB VIP.


This seems to work but the downside is that there is no real load balancing anymore. Hope that helps.


Thanks,

Marcus

Link to comment
Share on other sites

  • 3 years later...
On 4/10/2018 at 9:47 AM, Marcus Mietner said:

Hi Chris,


sorry for my late answer - account problems.


Unfortunately I was only able to implement a workaround.


1. I configured a LB VIP with a rewrite policy to alter the HTTP host header to the FQDN of service-a. Then I bound service-a to the VIP.

2. I repeated step one for service-b but created the second VIP as non-adressable (optional).

3. Then I added the second LB as backup virtual server (protection feature) to the first LB VIP.


This seems to work but the downside is that there is no real load balancing anymore. Hope that helps.


Thanks,

Marcus

 

Hi Marcus,

 

Is this still your favourite way or did you find a better solution since 2018?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...