Mike Howells's Blog

Just another WordPress.com site

Proxying requests to the published site using ISA Server or Threat Management Gateway

Posted by Mike Howells on August 7, 2010

In ISA Server 2004\2006 or Forefront Threat Management Gateway 2010 the “Proxy requests to published site” setting is one of the most confusing yet simple configuration options when publishing a server.

When you publish a website using the website publishing rule feature the default setting is to select the “Requests appear to come from the Forefront TMG computer” radio button available in the To tab of the website publishing rule’s properties dialog box. This is what I would call the “safe” option but as we’ll find out not necessarily the correct option for your environment (see image below):

Note: The default setting for publishing non-web server publishing rules is set to “Requests appear to come from the original client.” More on this specific setting at the end of this article.

TMG Listener

TMG Listener

With the setting “Requests appear to come from the Forefront TMG computer,” the logic is as follows:

The request comes into TMG and TMG sends it back to the web server. When TMG does this it changes the “Source IP” address field in the IP Header to its Internal adapter IP address. When the web server sees this request (assume it’s on the same logical segment as TMG), it sees the source IP is TMG. The web server then checks its routing table and says “This address is directly accessible to me. All I have to do is ARP for this IP and if I get a ARP response, I’ll deliver it directly to that host.” The response is complete as far as the web server is concerned.

Now, with the setting “Requests appear to come from the original client,” the logic goes like this:

The request comes into TMG and TMG sends it back to the web server. When TMG does this it leaves the “Source IP” address field in the IP Header alone (i.e. the external client’s IP is maintained.) When the web server sees this request (assume it’s on the same logical segment as TMG) it sees the Source IP as someone on the Internet. The web server then checks it’s routing table and says “This address isn’t directly accessible to me. My routing table says that if I don’t have a more specific route I’ll just punt and send it to my default gateway. Let me ARP for the gateway and if I get a response, I’ll deliver it to that system”. The request is now done as far as the web server is concerned.

You can see this behavior by opening a command prompt and typing “netstat -ano” without the quotes. This command displays your current network connections. You will be able to see the internal TMG source IP address or the client source IP address depending on the setting you have in TMG.

With the setting for “Requests appear to come from original client” it is essential that the return path for the responses from the web server honor the incoming path of the request. In other words, if the request came in from TMG and this setting is enabled, then the response has to go out through TMG as well. In other words, if you select the option “Requests appear to come from the original client” you must have the web server’s default gateway set to the TMG’s internal IP address! This begs the question as to why can’t TMG’s response go out some other device for the response such as another internal router? There are two reasons for this:

1) If the other device is capable of stateful inspection, it will not have any state for the response from the web server since the original packet came in through TMG.

2) Even if that device doesn’t perform stateful inspection it most likley does NAT. As the response goes through that other device, the Source IP will get changed to the NAT device’s IP and by the time the original client gets the response, the Source IP is not who the client sent it’s request to and it will drop the response.

They say a picture is worth a thousand words and in this case a graphical representation of what is going on helps. Below are four graphs depicting the four possible scenarios.

Scenario 1: Requests appear to come from the TMG computer. Default Gateway is TMG.

The below graph shows a client request traversing through TMG with the default setting of “Requests appear to come from the Forefront TMG computer.” The default gateway of the web server is set to TMG. This configuration will work but the downside to this configuration is that the web log files will only contain the IP address of the TMG’s internal interface obfuscating the true source of the request. This is a surefire way to infuriate the marketing folks, which for some of you may actually be an enjoyable thing to do. This scenario is a safe option but totally unnecessary in my opinion. If the Web server’s default gateway is set to the TMG server then there is no reason to have the requests appear to come from the Forefront TMG computer unless you want to purposely obfuscate the IP addresses in the web log files.

Requests appear from TMG, DG=TMG

Requests appear from TMG, DG=TMG

Scenario 2: Requests appear to come from the TMG computer. Default Gateway is a router.

The below graph shows a client request traversing through TMG with the default setting of “Requests appear to come from the Forefront TMG computer.” The default gateway of the web server is set to another router. This configuration will work but you have the same downside to this configuration as scenario 1 in that the web log files will only contain the IP address of the TMG’s internal interface. You will typically encounter this scenario in larger enterprises where they likely have a more complex routing infrastructure and they want the web server’s default gateway set to a router for policy reasons.

Requests appear from TMG, DG=Router

Requests appear from TMG, DG=Router

Scenario 3: Requests appear to come from the original client. Default Gateway is TMG.

The below graph shows a client request traversing through TMG with the setting of “Requests appear to come from the original client.” The default gateway of the web server is set to TMG. This is the most common scenario and the one that I use almost exclusively. This configuration will work and the web log files will contain the client’s Source IP address. I can hear the marketing folks jumping for joy.

Requests appear from client, DG=TMG

Requests appear from client, DG=TMG

Scenario 4: Requests appear to come from the original client. Default Gateway is a router.

The below graph shows a client request traversing through TMG with the setting of “Requests appear to come from the original client.” The default gateway of the web server is set to a router. I’ve saved the worst scenario for last because this is the scenario where people get into trouble.  This scenario will not work because the client’s source IP address is maintained all the way to the TMG server but the TMG server forwards its response out through its default gateway breaking the chain of communication.

Requests appear from client, DG=Router

Requests appear from client, DG=Router

The question then becomes how can you maintain the client’s Source IP address in the web logs in this scenario?  The answer is to use the X-Forwarded-For HTTP header field.  This is a de facto standard for identifying the originating IP address of a client connecting to a web server through an HTTP proxy or load balancer. Checkout the below article that describes how to use Winfrasoft’s X-Forwarded-For client for ISA and TMG server:

http://www.isaserver.org/tutorials/X-Forwarded-For-ISA-Firewall-Track-Originating-Client-Web-proxy-Chain-IIS.html

At the beginning of this article I briefly mentioned that the default setting for publishing non-web server protocol publishing rules is for the request to appear from the original client. So, the question then becomes why is this default setting different from publishing standard website publishing rule? I came across a possible scenario which may explain the reason. When publishing the latest version of a Microsoft CRM website you must use HTTPS.  Microsoft CRM uses forms-based (or claims-based) authentication so that you log in using a secure form to gain access to your CRM website. What if you want to securely publish CRM for multiple companies using a wildcard SSL certificate? You would purchase a wildcard SSL certificate (i.e. *.example.com) and then you would create a non-web server protocol publishing rule in TMG using the HTTPS protocol. This wildcard SSL certificate then allows you to host CRM for multiple companies such as company1.example.com, company2.example.com and so on using a single HTTPS web listener. Microsoft CRM has intelligence built into the form whereby it inspects the URL that you are sending it and then depending on the URL it will forward you to the proper CRM database on the back end. This behavior only appears to function properly when you have the HTTPS rule set to have requests appear to come from the original client. If you have the other setting applied where the TMG server replaces your source IP with its IP address you will no longer get a form to sign on with but instead you will be presented with a pop-up window to logon to the domain.

HTTPS Listener

HTTPS Listener

Advertisement

8 Responses to “Proxying requests to the published site using ISA Server or Threat Management Gateway”

  1. Hugh Redmon said

    I am trying to convince our IT folks to use Scenario 3 from above but they say it won’t work with our current network configuration. They are mostly concerned that the back-end applications on other servers that the website uses won’t be able to accessible to the web server if the default gateway is set to the TMG server. Did you ever encounter this scenario? Is there a solution? My network guys are stonewalling on this but I think we have other options. Currently our web server’s default gateway is set to another router. Being a marketing guy who knows something about networking, I am trying to get them to examine possibilities where we can make scenario 3 work. Any suggestions?

  2. Yes I have encountered that scenario. If you want to keep the web server’s default gateway set to the TMG server you can add static routes on your web server to get to any internal server that may need access to it. This would be the path of least resistance for you as opposed to implementing a complex routing protocol.

  3. Neil Kirby said

    Thanks for this Mike. I have been trying and trying to get scenario 4 to work for a while now. Before I found this, I had worked what was causing my setup not to work, but not why (if that makes sense) This article explained the situation perfectly. You have saved me continuing to bang my head against it trying.

    • Jon Sauter said

      This isn’t entirely accurate. The web server’s default gateway does not need to be set explicitly to the TMG server or array. Nor does it necessarily require a complex routing protocol as Mike suggests. Rather the default routing path must pass through TMG. You can point your servers at an internal router as long as the router’s next-hop (or downstream default route) ultimately passes through TMG. The caveat here, of course, is that this configuration essentially turns the entire network into SecureNAT clients for TMG. That’s not necessarily a bad thing (in fact many would argue that it’s the right approach–but that’s another topic) but it’s definitely an implication that would require serious planning and consideration. If you don’t want to go this route, you could set the default gateway of the web server explicitly, as indicated in this article, and use static routes for other internal subnets, as suggested by Mike.

  4. May said

    Howdy, i read your blog occasionally and i own a similar one
    and i was just wondering if you get a lot of spam feedback?

    If so how do you protect against it, any plugin
    or anything you can advise? I get so much lately it’s driving me insane so any help is very much appreciated.

  5. Hi Mike,

    I just found this article and it’s a great help and well written, but I’m struggling to work out Scenario 2.

    Surely if the Source Address of the request’s IP packet header is set the the TMG server’s internal IP address, then regardless of the Web server’s default gateway, the response will be routed back to the TMG server via the other internal router, not out to the Internet as depicted?

    Thanks, Tom

    • Tom: I believe you found an error in my scenario 2 portion of the posting. What I should have said is the web server’s default gateway may be set to a router and not TMG’s default gateway. I’ll make the correction.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

 
%d bloggers like this: