Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Clear all filters
Answers

iRule - Switch IP to Host Name

Hello,

We have a special case were we have a customer sending traffic by IP instead of host name. Instead of https://test.f5.com/api/example there hitting us as https://37.123.55.109/api/example. This was causing an issue for us in regards to the IIS/Bindings expecting test.f5.com but was getting an IP. I have attached the below iRule to the bip-ip 443 virtual server and traffic seems to be flowing, I'm getting a response back from server but now I'm getting an SSL error because the url still shows the IP. Is my iRule missing anything?

when HTTP_REQUEST { if {[HTTP::uri] contains "api/example" } { HTTP::host test.f5.com } }

Thank you for the help!

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Would this irule help?

when HTTP_REQUEST {
  if { ( [HTTP::host] eq "37.123.55.109" ) and 
      ( [HTTP::uri] starts_with "/api/example" ) } {
    HTTP::respond 301 Location "https://test.f5.com[HTTP::uri]"
    }
}

Not got my lab fired up so would need to verify syntax and test.

Hope this helps,

N

0
Comments on this Answer
Comment made 17-Jul-2018 by sysadmin_2015 256

Hello,

Thank you for your reply, but wont this kick out the traffic to https://test.f5.com? we need the traffic to stay on the Big-IP and go to a POOL of servers.

Thank you,

0
Comment made 17-Jul-2018 by nathan 7337

this should only affect traffic going to the IP address, rather than test.f5.com

0
Comment made 17-Jul-2018 by sysadmin_2015 256

Yes, but wont test.f5.com be resolved and traffic send to that location. We're trying to keep the traffic on the Big-IP/Pool and sent to a diff set of servers than those behind test.f5.com.

Thank you,

0
Comment made 17-Jul-2018 by nathan 7337

When a client requests test.f5.com the host header will be the same and not match the IF statement. The only traffic the irule will match is any which is a request to the IP address plus a URI of /api/example

N

0
Comment made 17-Jul-2018 by sysadmin_2015 256

Sorry for the confusion. test.f5.com resolves to an Amazon ELB. That traffic is separate from this. We have a tunnel with a specific customer and they need to be NAT’d by ip to us. We can route the traffic to the pool and add a host header for test.f5.com by irule so that the binding picks it up and the servers responds. The problem is the browser url still shows the IP address which then causes a SSL error.

0