how can I use ngrok to a subfolder of localhost - iis

I want to use ngrok to display a web site in IIS, the site is not located in default website (http://localhost) but in a subfolder as an application in IIS like this...
localhost
--wordpress
And I can the access that site like this http://localhost/wordpress/ when browsing locally
How can I use ngrok to point to this folder, the only thing I get to work is ngrok http 80
but that only display the content of default web site (localhost) and that is not what I want to show, I want to expose the localhost/wordpress folder. Can that be done?

You can use URL Rewrite to rewrite http://localhost/ to http://localhost/wordpress/:
<rewrite>
<rules>
<rule name="Test">
<match url="(.*)" />
<action type="Rewrite" url="/wordpress/{URL}" />
</rule>
</rules>
</rewrite>

Related

IIS Reverse proxy/Global URL Rewrite for "/api/" folder for all sites

I would like to reverse proxy any requests to an IIS instance for any sites where the request is in the '/api/' folder. I set up a server farm and have the reverse proxy working for everything using the '*' wildcard, but when I want to limit the scope to a RegEx it will not rewrite/proxy to the backend server. The steps I took at the IIS INSTANCE level:
Set up a web farm - only one server in it, machine2
Set up a rewrite for '*'
Tested against 'http://machine1/site1/api/api1' - it was successfully routed to machine2/site1/api/api1
Changed inbound rule from Wildcard to Regular Expressions
Changed Pattern to '.(/./api/.*)' (without the single quotes)
Tested against 'http://sarjhennew10vm/site1/api/api1'
Request was not routed to machine 2.
Below is a snippet from my applicationHost.config [the root of IIS].
<rewrite>
<globalRules>
<rule name="ARR_Farm1_loadbalance" patternSyntax="ECMAScript" stopProcessing="true">
<match url=".*(\/.*\/api\/.*)" />
<action type="Rewrite" url="http://Farm1/{R:1}" />
</rule>
</globalRules>
</rewrite>
<proxy enabled="true" />
Is it possible to to a global URL re-write to the server farm for any site on the instance for specific folders?
Edit: It was answered below - I am including a picture in case others run into this. The test pattern isn't clear to me - and counters documentation found here.
Your pattern is incorrect, you can try below code, and change the rewrite url to https://Farm1/{R: 0}
<rule name="ARR_Farm1_loadbalance" patternSyntax="ECMAScript" stopProcessing="true">
<match url=".*(\/api\/.*)" />
<action type="Rewrite" url="https://Farm1/{R:0}" />
</rule>

IIS - Redirect http requests from url to another url in the same folder

I have an asp page as part of of web application hosted on IIS8. I would like to set up http redirection from this page to another aspx page within the same site.Isn't there a straightforward setting I can use in IIS? I've looked at http redirect and url rewrite with little luck.
Requests to
http://localhost/example.asp
needs to be redirected to
http://localhost/example.aspx
I figured it out. I was missing the URL Rewrite module.It can be downloaded here.Once you download, install the url rewrite module and it will look like this.Open the feature and add the rule.
Once you add a new rule it will show up in the web.config file under system.webserver tags or you can add it to the web.config file directly.
<system.webServer>
<rewrite>
<rules>
<rule name="asp_to_aspx" stopProcessing="true">
<match url="^example.asp$" />
<action type="Redirect" url="http://localhost/example.aspx" />
</rule>
</rules>
</rewrite>
</system.webServer>

HTTP to HTTPS on domain hosted in VPS using IIS

I have a domain which has the DNS setting pointing to a VPS.
The VPS has an IIS 10 instance which hosts the simple website using html using bootstrap.
I installed an SSL certificate and added bindings for the https part.
I am able to browse the domain on http and https.
I added the following rule to the web.config:
<system.webServer>
<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="Permanent" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
However this does not seem to help. I am still able to browse on http.
I tried the following:
Tried installing URL Rewrite but it looks like Windows Server 2016 and IIS 10 does not allow the installation
Tried enabling Requires SSL option.
This shows the website in http without images but with text
The website is properly displayed in https
What am I missing here?
I was installing the wrong URL rewrite.
This article helped me fix the problem with the right links.
Automatic IIS redirect http to https on Windows Server 2016: https://gridscale.io/en/community/tutorials/iis-redirect-http-to-https-windows/

IIS Url Rewrite overwriting external urls

On my development machine, I am trying to configure IIS as a reverse proxy to forward requests coming in port 443 to a nodejs application running locally.
The requests are getting forwarded fine, but sometimes the the nodejs application tries to redirect the browser to an external site and the IIS url rewrite module change that also to point to the local server.
I am accessing the site using https://localhost/test
IIS reroutes the requests to the node app http://localhost:14819/test
The node app returns an http 302 with location header set to https://example.com/someroute
IIS transforms this to https://localhost/someroute
I want the external urls to be untouched by IIS. How to do this?
Here is my Web.config content
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="ReverseProxyInboundRule1" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^test(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="^localhost" />
</conditions>
<action type="Rewrite" url="http://localhost:14819/test{R:1}" logRewrittenUrl="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
If you have any redirect coming back from the backend proxy and you do
not want to redirect the Location header coming ,You can do that by
unchecking "Reverse rewritehost in response headers" in Application
Request Routing
Select the server node in IIS manager
Go to Application Request routing Cache
Click on Server proxy Settings
UnCheck "Reverse rewritehost in response headers"

IIS7 rewrite for REST not working

I have a REST service and am trying to remove the .svc - a common task/problem.
The application on the server is in a virtual directory under the default website (not sure if this is important)
I have installed the IIS Rewrite Module and have tried to create a rewrite rule for this.
http://blah.me.com/here/thingys/get?id=1111
to rewrite to this:
http://blah.me.com/service.svc/thingys/get?id=1111
In my web.conf the following is created:
<rewrite>
<rules>
<rule name="GEAPI /here/ to /service.svc/">
<match url="^(.*?)/here/(.*)$" />
<action type="Rewrite" url="{R:1}/service.svc/{R:2}" />
</rule>
</rules>
</rewrite>
In the GUI the regular expression does test correctly.
However - when I run this in a browser on the server, it gives the following 404 error:
Error Code 0x80070002
Requested URL http://blah.me.com:80/here/thingys/get?id=1111
Physical Path C:\MyApp\here\thingys\get
C:\Myapp is the correct physical directory the virtual directory in IIS is pointing to.
Is there something I am missing here ? I have tried creating this rule under both the default website and the app, both separately and together.
Big thanks
P
You could use this:
<rewrite>
<rules>
<rule name="GEAPI /here/ to /service.svc/">
<match url="^(.*)here(/.+)" />
<action type="Rewrite" url="{R:1}service.svc{R:2}" />
</rule>
</rules>
</rewrite>
IIS will only give you the part of the URI that's after http://blah.me.com/

Resources