I'm having some trouble with IIS and apache working on the same server. Specifically, any redirects that apache does don't replace the website domain with the target domain. Here's an example: Trying to redirect to https://s3.amazonaws.com/company-documentation/Help/Product/index.html instead redirects to https://website.company.com/company-documentation/Help/Product/index.html

I currently have it set up so that IIS redirects any traffic to apache and rewrites the url to hide the non-standard port number. The following are the IIS rewrite rules I have setup and the apache htaccess redirects.

Here's an htaccess root folder redirect rule in apache:

# Turn mod_rewrite on
RewriteEngine On

RewriteRule "^Documentation/Product/(.*)$" "https://s3.amazonaws.com/company-documentation/Help/Product/$1" [L,NC]

This is the IIS web.config:

<?xml version="1.0" encoding="UTF-8"?>
                <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                    <match url="(.*)" />
                    <action type="Rewrite" url="http://website.company.com:8081/{R:1}" />
                        <set name="HTTP_ACCEPT_ENCODING" value="" /> 
                <rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
                    <match filterByTags="A, Form, Img" pattern="^http(s)?://website.company.com:8081/(.*)" />
                    <action type="Rewrite" value="http{R:1}://website.company.com/{R:2}" />
                    <preCondition name="ResponseIsHtml1">
                        <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />

The apache htaccess rewrite works fine on the current production server where only apache is installed as a web server. The new server needs to have both IIS and apache on the same server, to serve both the CRM and the website. Any suggestions on how to make this work?

EDIT: I'm not sure that having the Apache server redirect to IIS for CRM requests will work because the ADFS installed on the server uses ports 80 and 443, which would need to be used to make Apache the default request handler for HTTP and HTTPS request.

  • Reverse it then, let Apache rewrite to iis, and then start project to throw out iss which is always good Idea! – kakaz Aug 25 '18 at 11:04
  • @kakaz I agree that there shouldn't be 2 web servers on the same machine, but that's currently inevitable. It's definitely possible that this will be fixed later. For now I just need to determine what sort of IIS rule, configuration, or match pattern will make a redirect to another domain work. – Cohaven Aug 25 '18 at 13:05
  • There's no problem to have as many web servers on one machine as you wish. There's a problem with iis what is completely different matter. – kakaz Aug 25 '18 at 14:23
  • IIS is that bad? I know I'm not liking it so far, but maybe that's just my inexperience with it. – Cohaven Aug 25 '18 at 15:21
  • In my opinion is so hard to configure and understand ( take a look about security model full of dependencies) it cannot be effectively used. And is very, very hard to backup and restore. So it is ( in my opinion) a crap software... – kakaz Aug 25 '18 at 15:23

The solution is to go the the ARR proxy settings and uncheck “reverse rewrite host in response headers“. Source: https://forums.iis.net/t/1176725.aspx

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.