IIS reroute just one site to Apache - iis

I'm trying to figure out how to reroute just one of our sites from IIS to Apache. I've followed several online tutorials and posts and nothing is working. I keep getting:
I've read that I need to do a reverse proxy using the URL Rewrite feature of IIS. So I did that and here are my settings:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpRedirect enabled="false" destination="" />
<rewrite>
<rules>
<rule name="ReverseProxyInboundRule1" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="http://localhost:8088/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Apache is on 8088 and if I hit localhost:8088, it works just fine. I've also added IUSR and IIS_IUSRS users to the directory permissions both having read and execute, list contents, and read permissions. I wouldn't think this would be that terribly hard.

When you need to rewrite IIS to apache, please remember to install ARR.
https://www.iis.net/downloads/microsoft/application-request-routing
Then please remember to enable Server node->application request routing cache->Server Proxy setting->Enable proxy.
Besides, could you access orchestrator.local without URL rewrite rule. Because, if this issue is caused by IIS, you should receive status code more than site can't be reached.

Related

Subversion behaving weirdly behind reverse proxy

I'm trying to migrate a Subversion server to a different machine, which is also already running IIS. Thus, I configured Subversion to run at port 81, and set up an IIS rewrite rule based on the host name:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="svn.foo.example" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^svn.foo.example$" />
</conditions>
<action type="Rewrite" url="https://svn.foo.example:81/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
In addition, "server proxy settings" are configured as follows (I think I left all of these as defaults):
enable
version pass through
keep alive
120-second timeout
reverse rewrite host in response headers
preserve IP in X-Forwarded-For
(The SVN server is VisualSVN 4.3.4; the IIS is Windows Server 2019 Version 1809.)
Where things get strange is that some stuff works, including on existing working copies. For example, I can:
use an existing working copy
add a file to that folder, and commit it
check that file's log
However:
use an existing working copy
check the log of a folder // works!
check the log of an existing file // does not work!
The latter fails with E160013: File not found. Indeed, if I look in the IIS logs, it returns 404.
If I instead (locally) check out that same file without the reverse proxy, I can get its log, so presumably, it's a problem with the proxying. But then why does it work if I add new files and check their logs?

How to force IIS to use a specific value for the http host header during a rewrite

I'm trying to create a rewrite rule that configures a web site to be used as a reverse proxy, but I'm having some issues setting the host http header to a predefined value different from the domain used in the rewrite (the objective is to use IIS as a reverse proxy for forwarding urls to sendgrid with a custom host value).
In order to illustrate the problem, I've created 2 web sites named url and sendgrid with the bindings url.com and sendgrid.net (I've added custom entries for these names on the hosts file so that the names can be resolved). Now, I need to redirect all requests received on the url web site to the sendgrid website, making sure that the request to the sendgrid web site sets the host http header to url.com. I've started by adding a rewrite rule to the url web site that looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="ReverseProxyInboundRule1" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{CACHE_URL}" pattern="^(https?)://" />
</conditions>
<action type="Rewrite" url="http://sendgrid.net/{R:1}" logRewrittenUrl="true" />
<serverVariables>
<set name="HTTP_HOST" value="url.madeira.gov.pt" />
</serverVariables>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
The applicationhost.config file has also been updated so that the HTTP_HOST can be changed:
<location path="url">
<system.webServer>
<rewrite>
<allowedServerVariables>
<add name="HTTP_HOST" />
</allowedServerVariables>
</rewrite>
</system.webServer>
</location>
In order to see what's going on, I've activated Failed Request Tracing and I've noticed that the host header file defined through the previous rule is not applied. I can see that the rule is processed and that the HTTP_HOST header is processed (SET_SERVER_VARIABLE), but when the request is rewritten, it will always set the http host to sendgrid.net (instead of setting it to url.com):
So, is there a way to force the use of a specific value to the host header when a IIS web site is configured to be used as a reverse proxy?
try to set the preserveHostHeader to true by following the below steps:
1)open IIS manager, select the server node.
2)double clic configuration manager.
3)from the section drop down select system.webServer/proxy
4)set preserveHostHeader to true
Note: if you are trying to change the request header it is not possible by using iis URL rewrite rule.

URL Rewrite Reverse Proxy on IIS only working on the server its self

I'm currently trying to set up a Gitea server on my Windows server 2016 standard server with Plesk installed. I have a subdomain setup which is git.thetofushop.net and I'm trying to make a Reverse proxy to point to the Gitea server which runs on port 3000.
this is my web.config for the subdomain
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="ReverseProxyInboundRule1" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="http://149.56.184.96:3000/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
But this only works internally on the server itself, it is not working outside of the server. You can visit the IP and port, but the reverse proxy point blank refuses to work. Now I'm not super adept with IIS, but I've tried what I can figure out from what I've found. If someone can give me a reason and an exact steps to fix this id. I am also open at this point to allowing someone to TeamViewer in and fix it as I've been trying to figure this out for 8 straight hours.
Thanks in advance

coldfusion IIS web.config for URL ReWrites getting 404 error

I have two separate websites on my server:
X:\Inetpub\wwwroot\MySite1\ and X:\Inetpub\wwwroot\MySite2.
I'm trying to set up some URL Rewrites, so I'm starting simple. I created a web.config file in X:\Inetpub\wwwroot\MySite1\web.config with the following code:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Contact" stopProcessing="true">
<match url="^contact$" />
<action type="Rewrite" url="/16_Contact.cfm" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
When someone enters the url "MySite1.com/contact", I want the browser to take them straight to "MySite1.com/16_Contact.cfm". But when I try it in a browser, I get a 404 error. I'm using an ancient version of Coldfusion (MX7), if that matters. Is there something obvious I'm missing?
It has been a while since I have used CF7, but I remember running into this issue, and it had something to do with the order in which CF and the rewrite module were added to the site in IIS.
First make sure your Coldfusion installation has the most recent patches, then try using the Web Server Configuration Tool that comes with Coldfusion to remove and re-add the Coldfusion modules/settings to your IIS site.

How can I get IIS to redirect to a virtual application if no path is specified?

My IIS setup has one site, bound to a domain. Let's call it: www.mydomain.com
The site folder itself is empty. This site hosts multiple applications and virtual directories. One of the applications is 'portal'.
What I want to do is accept any incoming request for www.mydomain.com or www.mydomain.com/ and redirect it to: www.mydomain.com/portal
I've got ARR and URL Rewrites up and running. I'm just not sure how to configure them for this.
A redirection rule like below will work.
Put the following web.config file to your web site's root folder. Or, update the existing one if you have.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="toPortal" stopProcessing="true">
<match url="^$" />
<action type="Redirect" url="/portal" redirectType="Found" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
You may want look at this tutorial to learn how to create url rewrite rules with IIS Manager. These xml nodes are not coming from my brain too.

Resources