So if somebody accesses http://server1.com (external ip) it forwards request to internal_ip1 and if it is http://server2.com it forwards request to internal_ip2
I pretty well understand that this involves analizing HTTP data (application level), and it's possible to accomplish such scenario using ISA Server or Varnish proxy.
But is it possible to do such a trick on cisco?
Yes, but you're going to have to remark DSCP bits in your interesting HTTP traffic. My solution below uses NBAR (Network-based Application Recognition) to remark DSCP bits on interesting traffic, with PBR (Policy-based routing) to route based on the aforementioned remarking.
- The router must support nbar; typically this is CPU-based routers, such as a Cisco 1800/1900 Series. The Cisco ASR also supports NBAR
- The router must support Policy-based Routing
- You must not use DSCP AF12, or AF13 anywhere else in the network.
class-map match-all CLASSIFY_HTTP_01
match protocol http host *server1.com*
class-map match-all CLASSIFY_HTTP_02
match protocol http host *server2.com*
set dscp af12
set dscp af13
ip access-list extended AF12
permit ip any any dscp af12
ip access-list extended AF13
permit ip any any dscp af13
route-map PBR permit 10
match ip address AF12
! This is a next-hop leading to internal_ip1
set ip next-hop 192.0.2.129
match ip address AF13
! This is a next-hop leading to internal_ip2
set ip next-hop 192.0.2.130
description [All HTTP ingress to this interface]
ip address 192.0.2.2 255.255.255.252
ip policy route-map PBR
service-policy input REMARK_HTTP
All that said, many times you're much better-off using a real HTTP load-balancer such as an F5 for this kind of thing. You can force a router to do it, but it's a bit unnatural.