Forum Discussion

Moinul_Rony's avatar
Icon for Altostratus rankAltostratus
Sep 03, 2020

Rewrite https request to http node IP and Port

Hi I am trying to implement a apache rewrite config into a F5 VS/iRule


I need to rewrite a https request to node IP and Port. I would also like to have a switch to rewrite to same node ip but different port based on the FQDN.


Something like



http request on rewrite to http://node:port1

http request on rewrite to http://node:port2


http request on rewrite to http://node:port3

http request on rewrite to http://node:port4


http request on rewrite to http://node:port5

http request on rewrite to http://node:port6


While I am figuring it out will be glad to get some idea's/irules :)




1 Reply

  • ok so the following irule works in a sense it matches fqdn and redirects to instructed node and port.. thats working perfect.

    when HTTP_REQUEST {
      switch -glob [HTTP::host] {
        fqdn1 { 
    	HTTP::header replace Host "????" # < --- I want to replace the IP of node with the fqdn to verify certificate
    	HTTP::redirect http://node:port1[HTTP::uri]
    	if { [HTTP::uri] starts_with "/uri-X" } { HTTP::redirect http://node:port2[HTTP::uri] }
        fqdn2 { 
    	HTTP::header replace Host "????"
    	HTTP::redirect http://node:port3[HTTP::uri]
    	if { [HTTP::uri] starts_with "/uri-X" } { HTTP::redirect http://node:port4[HTTP::uri] }
        fqdn3 { 
    	HTTP::header replace Host "???"
    	HTTP::redirect http://node:port5[HTTP::uri]
    	if { [HTTP::uri] starts_with "/uri-X" } { HTTP::redirect http://node:port6[HTTP::uri] }

    But... the rewrite of host is not working. I tried putting in node IP, the fqdn etc but no dice... if this somehow works i will be happy 🙂

    what am I missing??