IIS V10 - URL rewrite conditional to destination

ESP IT Guy 26 Reputation points
2022-08-31T02:58:14.93+00:00

Hello,

I have an op-prem web app that is reverse proxied behind IIS on a web server, I've run into an issue when enabling SAML authentication with 365.

Initiating auth works and the login page opens, username, password and MFA are entered with no issue. I then get an error saying "Application with identifier 'https://192.168.0.5:8443/app/saml' was not found. I'm not sure why the request is going out with the internal IP address of the Application server (not the web server) but I'm looking for a solution to this. I've analyised plenty of traffic both internally and externally and I don't see this ip address being exposed at any other time.

My question: is it possible to create a URL rewrite rule that turns any https://192.168.0.5... into https://application.domain?

There could be more to it than this and the traffic isn't going via the web server and the application itself could be configured/misconfigured to give this result. Those are questions I'm still trying to answer.

Any comments appreciated.

Internet Information Services
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Dillon Silzer 54,286 Reputation points
    2022-08-31T03:09:11.183+00:00

    Hi @ESP IT Guy

    You could try a rewrite rule for an IP to a Domain:

    https://serverfault.com/questions/286295/iis7-5-redirect-ip-to-domain

    Example from the above Server Fault Question

    web.config (when HTTP_HOST is an IP). You need URL Rewrite module to be installed (v1 is already bundled with IIS 7.5, but you may want to upgrade to v2). Works fine locally on Windows 7:

    <?xml version="1.0" encoding="UTF-8"?>  
    <configuration>  
        <system.webServer>  
            <rewrite>  
                <rules>  
                    <rule name="IP Hit" stopProcessing="true">  
                        <match url="(.*)" />  
                        <conditions>  
                            <add input="{HTTP_HOST}" pattern="192.168.0.5" />  
                        </conditions>  
                        <action type="Redirect" url="http://www.example.com/{R:1}" redirectType="Permanent" />  
                    </rule>  
                </rules>  
            </rewrite>  
        </system.webServer>  
    </configuration>  
    

    --------------------------------------

    If this is helpful please accept answer.

    0 comments No comments