iis 7 subdomain rewrite reverse proxy to internal servers - url

On Server2008 systems, ARR/URL rewrite installed. Incoming traffic to ARR server ('pirate.mydomain.com'), that server in DMZ. Internal IIS servers (Server 2008/URL rewrite), single IIS site ('static.mydomain.com') containing dept sub-sites (static.mydomain.com/deptone, static.mydomain.com/depttwo, etc).
At server level on ARR server, ARR server proxy settings: 'enable proxy' enabled, 'useurl rewrite to inspect incoming requests' enabled, 'reverse proxy' set to 'pirate.mydomain.com'.
Intent is to have deptone.mydomain.com rewritten (not redirected) to static.mydomain.com/deptone .... and depttwo.mydomain.com rewritten to static.mydomain.com/depttwo .
URL should not change in the visitors' browser.
At IIS site level for 'pirate.mydomain.com', URL rewrite rule as follows:
<rule name="deptone redirect" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="^(www.)?pirate.mydomain.com/(deptone)(.*)" />
</conditions>
<action type="Rewrite" url="http://static.mydomain.com/deptone{C:3}" appendQueryString="false" />
</rule>
THis is not working; I am getting 400.0 error ('max forwards limit').
Need guidance for URL rewrite rule for this process. Have been to the IIS forums/help, but still cannot get this working.
Thanks.

Related

How to port NGINX config from IIS

I have a front controller setup on IIS which I need to convert to NGINX on Docker.
Basically on IIS I have a virtual directory /we which maps to the application code at /var/app/we. When file is requested, if its not found, it is rewritten to /we/index.cfm?path_info=/{R:0}.
E.g. if a user requests http://example.com/sub1/test.cfm it is rewritten as http://example.com/index.cfm?path_info=/sub1/test.cfm.
I have tried various things like setting up a virtual directory alias in NGINX like this
location /we {
alias /var/app/we;
}
and then adding a rewrite rule but I just can't get it to work. Can someone please help?
The rule on IIS which I'm trying to convert is below:
<rule name="Redirect the File" enabled="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(flex2gateway|jrunscripts|cfide|cfformgateway|railo-context|files|images|javascripts|miscellaneous|stylesheets|rewrite.cfm|index.cfm)" negate="true" />
</conditions>
<action type="Rewrite" url="/we/index.cfm?path_info=/{R:0}" appendQueryString="true" />
</rule>
You can try the script from this link: iis-to-nginx.
Automated script to convert IIS rewrite rules to nginx rewrite format the code convert rewrite IIS rules to nginx rewrite format, you can import the output into the nginx config file.

IIS Rewrite Stopped Working for specific URL

We are trying to integrate OHIF with Orthanc Server. and We are using MVC application to integrate.
When have installed IIS, Orthanc Server on a EC2 machine.
We have configured IIS rewrite, where we will rewrite of the response of the orthanc server.
This was working fine until few weeks back, Now all of sudden the rewrite is not working for few URL. No code changes done.
Please help us on this.
https://book.orthanc-server.com/faq/iis.html
<rules>
<clear />
<rule name="ReverseProxyInboundRule1" stopProcessing="true">
<match url="^orthancserver/(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="http://127.0.0.1:8042/{R:1}" />
</rule>
</rules>
All URL Redirect working. And already installed Rewrite Module and I have enabled the proxy too.

http to https redirect url using web.config but getting HTTP Error 500.19 - Internal Server Error

I was try to redirect http to https url using web.config and change in web.config as below code. but it was getting error of "HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid."
But if i remove this code in web.config its working fine. so can you help me what should do change in it or something wrong in it.
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}"/>
</rule>
</rules>
</rewrite>
I think If you want make requests to HTTPS.
You should follow this steps,
SSL Certificate for site should be installed.
Site properly installed and configured for SSL (site set up and binding in IIS configured).
URL Rewrite is installed on the server.
one more thing the code which you written url rewrite it is correct.

Azure Deployment slots whitelist ip

I currently started to work on an web app, in ASP.NET MVC, hosted in azure as an web app. I created a deployment slot (staging, not a production slot) and i would like to know what should i do to block access on that slot from all IP addresses, excepting white listed ones.
I tried from web config by adding this part of code there.
<rules>
<rule name="Block unauthorized traffic to staging sites" stopProcessing="true">
<match url=".*" />
<conditions>
<!-- Enter your staging site host name here as the pattern-->
<add input="{HTTP_HOST}" pattern="^mysite\-staging\." />
<!-- Enter your white listed IP addresses -->
<add input="{REMOTE_ADDR}" pattern="123\.123\.123\.1" negate="true"/>
<!-- Add the white listed IP addresses with a new condition as seen below -->
<!-- <add input="{REMOTE_ADDR}" pattern="192\.255\.42\.2" negate="true"/> -->
</conditions>
<action type="CustomResponse" statusCode="403" statusReason="Forbidden"
statusDescription="Site is not accessible" />
</rule>
</rules>
But on deployment it returns this error from the server:
Module IIS Web Core
Notification Unknown
Handler Not yet determined
Error Code 0x80070032
Config Error The configuration section 'rules' cannot be read because it is missing a section declaration
IIS Version 10.0.
Do you know how should i do to restrict access as mentioned above (maybe something similar that you tried and worked)
Thanks!
Not sure if it was a typo when you pasted the config into your questions, but you are not closing <rules> correctly. Change the final <rules> to </rules>

IIS8 and URL redirect using URL Rewrite Module

I have two sites running on a Server 2012 R2 web server:
firstSite, port 80
secondSite, port 1234
Right now, users have to type in the host name, port number, and sub folder in order to view the 'Second Site' http://webServer:1234/subFolder.
I'm trying to simplify the URL so that all users can just type in the URL site.myDomain.com and have it (permanently) redirected to site.mydomain.com:1234/subFolder.
I've tried applying the following rule on my secondSite:
<rewrite>
<rules>
<rule name="Redirect" stopProcessing="true">
<match url=".*" />
<action type="Redirect" url="http://site.mydomain.com:1234/subFolder" />
</rule>
</rules>
</rewrite>
But doesn't seem to do anything.
A CNAME record has already been configured in DNS for site.myDomain.com to resolve to http://webServer.
I just need help with getting the redirection to 'secondSite' at port 1234.
I assume the first site is hosted on IIS and the rule is running within the context of the first site. If so, it should work...to validate your setup, I'd start with this article and the augment with your use case:
http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module
<configuration>
<system.webServer>
<httpRedirect enabled="true" exactDestination="true" httpResponseStatus="Found">
<add wildcard="/some/folder/path/" destination="/new/folder/" />
</httpRedirect>
</system.webServer>
</configuration>

Resources