Apache VHost rewrite rule not working as it should

by JasonPZOO   Last Updated May 15, 2019 15:04 PM

I have setup an Apache server inside my domain and have been creating VirtualHost in the httpd-vhosts.conf file. Up until now this has worked without issue, I have a few DNS entries externally that point to our gateway and the VirtualHost's either direct the request to a site on that server or I use a ProxyPass to send the traffic to the server that is hosting another site.

The new site we have installed does react the same as the other sites in that the standard ProxyPass line returns with a 401 error unauthorised access. If I go straight to the hostname rather than the VirtualHost Server name the page returns with no issue.

Eg:

ServerName test
ServerAlias test.domain.org.uk
ProxyPass / http://SERVERNAME/SSM/
ProxyPassReverse / http://SERVERNAME/SSM/

ServerAdmin [email protected]

ErrorLog "logs/test-access.log"
CustomLog "logs/test-access.log" common

So if I go to http://test or http://test.domain.org.uk I get the 401, if I go to http://SERVERNAME/SSM I don't have an issue.

test and test.domain.org.uk are both in DNS and if I point their CNAME's to the actual server rather than the webserver the pages load fine. But that doesn't help as I would like to have this site available externally.

The web.config file for this site has a rewrite rule which is no different than other sites I have setup like this.

    <rewrite>
        <rules>
            <rule name="Proxy" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
                <match url="*" />
                <action type="Rewrite" url="http://SERVERNAME/SSM/{R:1}" />
            </rule>
        </rules>
    </rewrite>

If I add /FormsLogin.aspx after /SSM on all the url's I do get a bit further but the page doesn't load correctly and sometimes returns with a proxy error.

The site is running on IIS and previous searches for the issue pointed me to enabling Anonymous Authentication, when I check, it is enabled but the Anonymous User Identity is set to specific User IUSR, would that have anything to do with the denied access from the webserver? Is there a way to set the rewrite to behave as if it is IUSR?

Hopefully someone can point me in the right direction.

Tags : url-rewriting


Related Questions


Updated May 15, 2015 23:01 PM

Updated February 21, 2017 21:04 PM

Updated March 03, 2017 10:04 AM

Updated April 24, 2017 01:04 AM

Updated May 04, 2017 01:04 AM