Forum Discussion
Forwarding traffic to specific port
Hi All
Building a IRule were a specific path is directed towards a node / member with a specific port.
To do so I created a datagroup (string) where each path has a value (port) So far the Irule below works fine, just with one node.
when HTTP_REQUEST { set URI [string tolower [HTTP::uri]] log local0. "Path is $URI" if { [class match $URI starts_with ITSM_URL_Port] } { set port [class match -value [string tolower [HTTP::uri]] starts_with ITSM_URL_Port] log local0. $port node $port } else { log local0. "no match - [HTTP::uri] "} }
But the next challenge will be when a second server is added. I tried several methods i.e. using the LB_SELECTED event were the IP address is captured in a variable and use in the node command like for example : node $server_address $port, were the server address is fetched from the [LB::server addr] command.
For example :
when HTTP_REQUEST { set URI [string tolower [HTTP::uri]] log local0. "Path is $URI" if { [class match $URI starts_with ITSM_URL_Port] } { set port [class match -value [string tolower [HTTP::uri]] starts_with ITSM_URL_Port] log local0. $port } else { log local0. "no match - [HTTP::uri] "} }
when LB_SELECTED {
set server_address = [LB::server addr } node $server_address $port
}
In the logging we see that the self-ip is returned instead of the real server address.
Any idea why the self-ip is returned instead of the server address? We running version 12.1.2
Kind regards
- Simon_BlakelyEmployee
Try the following - shifting the node command to the HTTP_REQUEST event
when HTTP_REQUEST { set URI [string tolower [HTTP::uri]] log local0. "Path is $URI" if { [class match $URI starts_with ITSM_URL_Port] } { set port [class match -value [string tolower [HTTP::uri]] starts_with ITSM_URL_Port] log local0. $URI selects $server_address:$port node $server_address $port } else { log local0. "no match - [HTTP::uri] " } } when LB_SELECTED { set server_address = [LB::server addr] }
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com