Having issues with Node Red and IIS URL Rewrite - iis

I'm new to both Node-Red as well as IIS.
I am using URL rewrite to rewrite localhost:1880 to https://example.com which will show the Node Red Flow Editor. I managed to get the Node Red Flow editor working fine with the URL rewrite and I am able to access it using https://example.com.
I am having issues with accessing the Node Red Dashboard (localhost:1880/ui) After doing the URL Rewrite, I am unable to access the dashboard https://example.com/ui. However, I am still able to do access the dashboard using localhost:1880/ui.
After this, I went to the settings.js and uncommented httpAdminRoot: '/flow'. This changed the url to access the Flow Editor (localhost:1880/flow).
I also uncommented the ui: {path: "/"} which changed the url to access the Dashboard (localhost:1880/).
Keeping the same URL Rewrite rules, I am still unable to access the dashboard with https://example.com but I am able to access the Flow Editor using https://example.com/flow.
This is the error I get after trying to access https://example.com
Inbound/Outbound Rules
Any help would be appreciated thanks!

Try to make a test with the URL Rewrite rule below. It could help you rewrite example.com/ui to localhost:1880/ui.
<rewrite>
<rules>
<rule name="test_rule" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="example.com" />
<add input="{REQUEST_URI}" pattern="^/ui$" />
</conditions>
<action type="Rewrite" url="http://localhost:1880/ui" />
</rule>
</rules>
</rewrite>
Output:
Further, you could modify the rule as per your own requirements.

Related

How to rewrite one image with another in IIS using URLRewrite

Here is my problem, I need to rewrite one image with another (don't ask why).
Simple URLRewrite rule is not working.
Every time someone fetch this URL: http://example.com/images/001.jpg
IIS should show 002.jpg (http://example.com/images/002.jpg)
web.config:
<rules>
<rule name="img1" stopProcessing="true">
<match url="images/001.jpg" />
<action type="Rewrite" url="images/002.jpg" appendQueryString="false" />
</rule>
</rules>
I tested your URL rewrite rule and it works normally on my side.
So please try to clear your browser’s cache and try again.
And do you get any errors? If not, you can only use FRT to view detailed messages.

IIS URL Redirect failing

I need to redirect URLs of the form:
http://server1.name.here/path1/path2/?num=123456
to:
http://server2.name.here/path3/path2/?num=123456
using the IIS URL Rewrite Module 2.0 on IIS 8.5. I've used a DNS alias to handle the server name redirection.
I've been using the user interface to configure the path rewrite but despite trying several variations and extensive research I cannot get my rewrite to work, which is slightly embarrassing as I feel this should be a simple rewrite. The web.config produced by the URL rewite user interface is:
<rewrite>
<rules>
<rule name="path rewrite" patternSyntax="ECMAScript" stopProcessing="false">
<match url="path1/path2/" ignoreCase="true" />
<conditions>
<add input="{QUERY_STRING}" pattern="num=[0-9]+" />
</conditions>
<action type="Rewrite" url="path3/path2/" appendQueryString="true" logRewrittenUrl="true" />
</rule>
</rules>
</rewrite>
When I try to open server1.name.here/path1/path2/?num=123456 I get a "403 - Forbidden: Access is denied." and the logs show no evidence that my URL is being rewritten or even flagged by the rewrite rule.
I'm sure I'm missing something obvious, can anyone enlighten me as to what I've got wrong?
Many Thanks Eden

What's the proper method to tweak the URL in IIS or in web.config?

I am using Sitefinity CMS, one of my website sections for my pages is showing up in the URL and it makes the URLs look not very friendly, the section name is 'Footer' and the URL looks like this:
http://www.domain.com/footer/press-releases/first-press-release
How do I change/rewrite this URL in IIS or in web.config and remove the 'footer/' only so the URL looks like:
http://www.domain.com/press-releases/first-press-release
Thank you
In Sitefinity 6.3 and above you can edit the URL structure:
http://www.sitefinity.com/developer-network/forums/general-discussions-/sitefinity-6-3-released
This means, that even if the page is under the Footer group page, then you can remove the /footer/ from the URL of the page.
Just edit the Title and Properties and click on Change next to the URL.
I'd like to suggest you take a look at the IIS module URL Rewrite
http://www.iis.net/downloads/microsoft/url-rewrite
It would allow you to add rules allowing the 301 redirect you appear to need.
With the module installed you could add this to your web.config file:
<rewrite>
<rules>
<rule name="PressRelease" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^first-press-release$" />
<conditions>
</conditions>
<action type="Redirect" url="http://{HTTP_HOST}/press-releases/first-press-release" appendQueryString="false" />
</rule>
</rewrite>

IIS Rewrite Map not working

I'm rebuilding a site using iis urlrewriting on both static and dynamic pages. The redirects are all working well. The rewrite module is working perfectly.
Since the site structure is changing, I need to be able to redirect "old" defunct urls to new pages. So, for example, www.sitename.com/research.asp needs to be redirected to www.sitename.com/news
I've followed the instructions to set up a rule using a rewrite map and placed the rule near the top of my webconfig file (just under the CanonicalHostNameRule). But whatever permutations I've tried in the rule, I just can get it to work. The redirects don't happen - I just get a 404 for the (non-existent) .asp page. The map just seems to be getting ignored entirely. Just to re-iterate, all my other rules are working fine.
I've tried turning off all other rules and just working with this one, but no luck. Equally, I've trawled this forum and others for suggestions (using REQUEST_URI rather than Filename, restarting IIS, recycling App. Pools, etc etc), but nothing seems to work. The "Redirect" url="{C:1}" just sends me back to the old asp page I'm trying to get redirected away from, if that makes sense. Nothing in FailedRequestTracing seems to help, either.
Am I missing something very obvious here?
The Rule:
<rule name="Redirect Rule" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny" trackAllCaptures="false">
<add input="{StaticRedirects:{REQUEST_FILENAME}}" pattern="(.+)" />
</conditions>
<action type="Redirect" url="{C:1}" appendQueryString="false" redirectType="Permanent" />
</rule>
The Map:
<rewriteMaps>
<rewriteMap name="StaticRedirects">
<add key="research.asp" value="news" />
<add key="blog.asp" value="news" />
<add key="mentors.asp" value="interviews" />
<add key="regulars.asp" value="opinion" />
</rewriteMap>
</rewriteMaps>
NB - there are lots of other static redirects to add to this once it actually works, which is why I wanted to use a map.

Azure Web Sites custom domain

I configured a custom domain for my Azure Web Site using CNAME records.
Everything works fine, except for the fact that I can access my site using both *.azurewebsites.net and *.com.
Isn't this a SEO issue, and can it be avoided so that I get *.com in both cases?
You can try with simple url rewrite rule in your web.config file:
<system.webServer>
<rewrite>
<rules>
<rule name="MyHostNameRule">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^domain\.com$" negate="true" />
</conditions>
<action type="Redirect" url="http://domain.com/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
Basically, it says that if request host doesn't match specified pattern, just rewrite it to domain.com/... If you have access to the IIS, you can use Url Rewrite module there, where this code can be created through a wizard.
One hint: when developing app and testing on localhost:port, it will rewrite url. To avoid that, put this rewrite rule in Web.Release.Config, and of course deploy your app to Azure WebSite in Release mode! Only thing you need is add xdt:Transform to rewrite element:
<rewrite xdt:Transform="Insert">

Resources