Microsoft Azure cannot start debugging because of the rewrite rule - azure

I'm trying to add an http to https redirection rule into my azure web roles web.config file but when I add it, It gives me the error which you can see in the image. I found out that the rule line is responsible for this error.
What can I do?
Servicedefinition.cscfg:

Does you cloud service definition have HTTPS setup locally. The error suggests you haven't. I would therefore use web.config transforms so that my locally running instance does not have the redirect and cloud deployments do or make https valid on your local debugging so that the debugger is connecting to the HTTPS. I assume you have both an http and https endpoint in your definition.

Finally i've found the reason. It wasn't anything about azure. This rule also rewrites the path of the debugattach.aspx, this is the reason why visual studio cannot start debugging. To fix this issue I added this rule:
<rule name="debug" enabled="true" stopProcessing="true">
<match url="^debugattach\.aspx" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="None" />
</rule>

Related

Can an Azure App Service redirect www to non-www?

Is it possible to redirect www to non-www at the azure app service level?
I need this at the app service level and not in the configuration file of my app. I have been able to get http to https working under the tls/ssl blade, but I don't see a way to redirect for www.
Do I need another resource like front door or application manager? I'd like to handle it in the app service itself.
My app server is running a docker container that is using an nginx server. I'm not an expert with nginx, and haven't been able to get the redirect to work in the nginx configuration. Plus, I'd like to set this up in my bicep file.
To rewrite a URL, you need to create a web.config file in your wwwroot folder and put the necessary entries in there, if you don't already have a web.config file for your site.
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect requests to default azure websites domain" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^yoursite\.azurewebsites\.net$" />
</conditions>
<action type="Redirect" url="http://yoursite.com/{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Original answer: https://learn.microsoft.com/en-us/answers/questions/193377/how-to-redirect-in-app-service

Having issues with Node Red and IIS URL Rewrite

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.

IIS Rewrite not working but redirection does

I am trying to get URL re-writing working on a IIS 8.5 server.
I am having the same issue as described in
this similiar post, that is a redirect works but rewrite does not.
The simple rule for testing purposes is:
<rule name="ReverseProxy" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="http://10.10.101.22:52797/{R:1}" />
</rule>
My goal is to rewrite URLs with only specific path to another internal server.
If I change the rule to redirect it works.
On a similarly configured IIS 8.5 server the rewrite rule works.
AAR is installed and Enable proxy is checked.
After installing AAR I had to restart IIS for the AAR icon to appear.
I could not see anything in Failed Request Tracing that explains why this is happening.
Does anybody have any suggestions?

URLRewrite "Redirect" rule works, but "Rewrite" rule fails (404)

I have following rewrite rule:
<rule name="First Rule" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^Tracking/(.*)" ignoreCase="true" />
<action type="Rewrite" url="http://www.example.com/" />
</rule>
This failes, calling http://www.myserver.com/Tracking/123 returns a 404.
However, if I change the action type into Redirect, the rule suddenly works fine, performing a redirect:
<rule name="First Rule" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^Tracking/(.*)" ignoreCase="true" />
<action type="Redirect" url="http://www.example.com/" />
</rule>
But I need a rewrite rule, as I need a reverse proxy to an internal server.
I'm working on a Windows 2008R2 Server (IIS 7.5), have "IIS URL Rewrite Module 2" installed,...
What is wrong with the Rewrite rule ?
Since you mentioned that you're setting up a reverse proxy to an internal server. If a URL Rewrite destination is outside of the server performing the rewrite, you will need to install Application Request Routing to enable proxy capabilities. After installing Application Request Routing (ARR), you'll need to go to its proxy settings and check the Enable Proxy feature. A full blog on this setup can be found here. If this has already been performed, I would recommend using Failed Request Tracing on both the reverse proxy and destination server (if the destination server is IIS) in order to better understand where the HTTP 404 response is coming from.

Using URL Rewrite for Cross-Domain Http Requests

I am trying to write an inbound rewrite rule that basically captures all the requests to the root folder /api/*, and rewrite it to api.v2.movideo.com respecting the HTTP vs HTTPS traffic.
I followed the step by step instructions here: http://code.movideo.com/Setting_up_IIS7_to_use_URL_Rewrite_2.0_for_Cross-Domain_XMLHttpRequest_Calls
I installed Application Request Routing http://www.iis.net/expand/URLRewrite
Followed all the steps on that page, removed the instructed headers, did everything by the book, but all I get is this:
HTTP Error 500.50 - URL Rewrite Module Error.
There is a problem with the resource you are looking for, so it cannot be displayed.
When I change the rule from REWRITE to REDIRECT, it works fine, but it redirects, not rewrites! Ugh. What's going on here?
Here is my Rule:
<rule name="ReverseProxyInboundRule1" stopProcessing="false">
<match url="^api/(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{CACHE_URL}" pattern="^(https?)://" />
</conditions>
<action type="Rewrite" url="{C:1}://api.movideo.com/{R:1}" />
<serverVariables>
<set name="HTTP_ACCEPT_ENCODING" value="" />
</serverVariables>
</rule>
(2nd question: Are there any problems or things I should know installing Application Request Routing? It added a new 'Server Farms' section in my IIS, hmmmm...I have no idea what this is all about. )
If there are processing rules AFTER this rule, consider setting the stopProcessing attribute to true
Because you are using a serverVariables node, you must add the server variable to the allowedServerVariables collection for your server. Your can do this from using the IIS UI (details here: Setting HTTP request headers and IIS server variables) or from the command line:
%windir%\System32\inetsrv\appcmd.exe set config -section:system.webServer/rewrite/allowedServerVariables /+"[name='boo']" /commit:apphost

Resources