IIS 10 is throwing the error
404 File or directory not found
Only when I try to access the url with subfolder path like this:
http://myserveraddress.com/object/181
So it works without the subfolder. The subfolder path is used by Angular to query a rest interface so there is no physical folder path behind it, just used for querying behind the schene.
This actually works when running on localhost but not on the server.
Is it possible to configure IIS such that it allows any url path even though the physical folder path does not exist?
This loos more like a handler configuration issue, and also if your server is a brand new server may be you haven't installed the handlers which is supposed to process your request, if i have to take a request if you haven't configured the rest handlers required it is goind to the static file handler which tries to look for a folder in the request url path and throw an error, if you already have a setup running, check all the handlers and pre-requisites installed there and mimic the setting over in the new server as well
The solution was to add this to the Angular client web.config file
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="AngularJS Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
More detail can be found here Get Angular2 routing working on IIS 7.5
Related
I try to install react(axios) in IIS and use node.js as server GET,POST work fine but PUT,DELETE (can use in internal) did not
I tested in Linux server node.js work fine, I try to solve for week such as ExtensionlessUrlHandler ,cors, etc. now I disable Request filter in IIS still did not work.
Failed to load resource: net::ERR_CONNECTION_RESET
(I can not upload picture.)
Common HTTP Features (4 of 6 installed)
Default Document
Directory Browsing
HTTP Errors
Static Content
Health and Diagnostics
HTTP Logging
Performance
Static Content Compression
Application Development
CGI
ISAPI Extensions
ISAPI Filters
WebSocket Protocol
Management Tools
IIS Management Console
web.config
<?xml version="1.0"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="React Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
This error may be caused by cookies and most often seen with chrome users.
You can try the following steps to solve your problem.
Go to Chrome settings > Privacy and security > Cookies and other site data > Cookie > All cookie and Site Data > Delete domain problem
Or you can refer to this link: Failed to load resource: net::ERR_CONNECTION_RESET
I have an app in the azure app service which has "index.html" setup as a default document in portal and also url rewrites in web-config (see below). If I go to the site with cleared history or chrome incognito mode it gives me a 404. I can hit the url directly on "mysite.com/index.html" and after that "mysite.com" will work too, but brand new browser session always 404.
I also have below in www_root in attempt to force "index.html" to load but no luck, any ideas?
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<!-- IIS URL Rewrite for react routes -->
<rewrite>
<rules>
<rule name="Angular Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
</conditions>
<action type="Rewrite" url="/index.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Try by removing '/' in url=/index.html and add appendQueryString="true"
The default document is the web page that's displayed at the root URL for a website. The first matching file in the list is used. To add a new default document, click New document.
So, you could remove the above and then try adding> In the Azure portal, search for and select App Services, and then select your app. In the app's left menu, select Configuration > Default documents.
If the app uses modules that route based on URL instead of serving static content, there is no need for default documents.
To isolate, try to configure web.config similar to this:
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="SPA">
<match url=".*" />
<action type="Rewrite" url="index.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Or If you wish to actually rewrite but not redirects, try enabling ARR with applicationHost.xdt file with in the site root folder. If you connect to your site using Kudu console, you will see the deployed files under your site\wwwroot folder - Kudu console (https://yoursite.scm.azurewebsites.net) > From the Kudu Console> Debug Console >> (CMD/PowerShell> Site > wwwroot. >> Shows-up all your deployment files.
I have sucessfully deployed nodejs app in azure. when I navigate to **https://my-app/xyz ** refresh page I see, You do not have permission to view this directory or page.
I tried to edit web-config but still it doesn't work. I am not sure If this is security issue or node.js is not able to serve anything for this route but on my local machine If I do refresh It doesn't show this issue. Thje picture above contains the directory structure and /client has Angular compiled files.Thank you
<system.webServer>
<rewrite>
<rules>
<rule name="RewriteRules" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
</conditions>
<action type="Rewrite" url="/index.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
I have experienced this error. I suppose you access the website via a virtual directory.
Make sure you have set the correct virtual directory for your app.
It should be the virtual path /xyz, Physical Path site\wwwroot\yourcustomfoldername. It will be something like this,
Make sure the Physical Path match the actual root directory of your web app in KUDU site.
I have a node app that has both a react native front end and a node API
I want to be able to just run npm install for both folders and then just have it run the start command "node server" (node/server/index.js) to have the node app running.
But I can't seem to figure out the release tasks to make this happen.
I am using the preview continous delivery that connects to visual studio online
In my opinion, it has nothing to do with continuous delivery. Since Azure App Service runs on Microsoft IIS, you'll need to have an IIS configuration file named web.config and should include the following section to match your requirement:
<handlers>
<add name="iisnode" path="./node/server/index.js" verb="*" modules="iisnode"/>
</handlers>
This indicates that the node/server/index.js file is a node.js site to be handled by the iisnode module.
<rewrite>
<rules>
<!-- First we consider whether the incoming URL matches a physical file in the /public folder -->
<rule name="StaticContent">
<action type="Rewrite" url="public{REQUEST_URI}"/>
</rule>
<!-- All other URLs are mapped to the node.js site entry point -->
<rule name="DynamicContent">
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
</conditions>
<action type="Rewrite" url="./node/server/index.js"/>
</rule>
</rules>
</rewrite>
These rewrite rules determine where your static content and dynamic content should be located in.
For a completed web.config file you can check this post out.
I'd like to start by saying I am very (VERY) new to Azure. I have just publish an AngularJS app and I've come across an irritating issue.
When publishing the app from visual studio the first time around, it placed the files inside site\wwwroot. This was fine because I then just changed the virtual path to look at the www subfolder.
So the new setting makes / equal to site\wwwroot\www
This is because the code for my site actually sits within this www folder. Everything worked! Great!
However, the next time I did a publish, the whole site was then places within site\wwwroot\www, meaning that to get to my index page I had to go to site\wwwroot\www\www.
For some reason by defining the 'Physical path relative to site root', it changes the whole publish path. This does kind of makes sense, but is there anyway around this issue? Possibly a different practice or setting I haven't come across yet.
Any tips or advice would be greatly appreciated!
Thanks in advance.
Since you have mapped / to site\wwwroot\www, your later publish would be applied to site\wwwroot\www. Per my understanding, you could directly deploy your web content under www to site\wwwroot via ftp tools, etc. Or you could use URL Rewrite instead of changing the virtual path for /. And your rewrite rules under the web.config file as follows:
web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="hide www sub directory" stopProcessing="true">
<match url="^www/(.*)"/>
<action type="Redirect" url="{R:1}" appendQueryString="true" redirectType="Permanent"/>
</rule>
<rule name="rewrite to sub directory">
<match url="^(?!www)(.*)" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="www/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Note: The we.config file is under site\wwwroot.
TEST:
Kudu
For accessing the index.html, you need to access https://brucewebapp.azurewebsites.net/www/index.html. Using the url rewrite rules, you could just access https://brucewebapp.azurewebsites.net/index.html as follows: