Fault 1: The IIS configuration causes that files or directories cannot be found when the page is refreshed
misconfiguration
The IIS web.config configuration is as follows
<? The XML version = "1.0" encoding = "utf-8"? > <configuration> <system.webServer> <rewrite> <rules> <rule name="test" patternSyntax="Wildcard"> <match url="*api/*" /> <action type="Rewrite" URL ="http://10.10.17.74:8085/{R:2}" /> </rule> </rules> </ staticContent> <mimeMap fileExtension=".glb" mimeType="application/glb" /> <clientCache cacheControlMode="DisableCache" CacheControlMaxAge ="3.00:00:00" /> </staticContent> </system.webServer> </ Configuration >Copy the code
Phenomenon of the problem
404 File or directory not found when refreshing the page.
Configured correctly
<? The XML version = "1.0" encoding = "utf-8"? > <configuration> <system.webServer> <rewrite> <rules> <rule name="index"> <match url="^((? ! (api)).) *$" /> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> </conditions> <action type="Rewrite" url="/index.html" /> </rule> <rule name="test" patternSyntax="Wildcard"> <match url="*api/*" /> <action Type ="Rewrite" url="http://10.10.17.74:8085/{R:2}" /> </rule> </rules> </ staticContent> <mimeMap fileExtension=".glb" mimeType="application/glb" /> <clientCache cacheControlMode="DisableCache" CacheControlMaxAge ="3.00:00:00" /> </staticContent> </system.webServer> </ Configuration >Copy the code
Description:
The mimeMap part is automatically appended after the media type is added
Error 405 is reported when POST calls background request
The symptom is shown in the following screenshot.
The incorrect configuration is as follows
The IIS web.config configuration is as follows
<rule name="index"> <match url="^((? ! (api)).) *$" /> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> </conditions> <action type="Rewrite" url="/index.html" /> </rule> <rule name="dl" patternSyntax="Wildcard"> <match url="*dl/*" /> <action Type = "Rewrite" url = {2} R: "http://10.10.17.74:9100/" / > < / a > ruleCopy the code
instructions
- The first rule in the configuration file captures all requests that do not contain the API, which is equivalent to routing to the redirect.
- The second rule in the configuration file redirects all requests containing dl to the background.
- 3, however, I now call the interface /dl/uaa/loginUser, which rule is matched, so there is a problem.
- 4. When invoking background interfaces, you need to spell the same matching string (such as API) before all interfaces. For details, see Correct configuration.
Configured correctly
<rule name="index"> <match url="^((? ! (api)).) *$" /> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> </conditions> <action type="Rewrite" url="/index.html" /> </rule> <rule name="dl" patternSyntax="Wildcard"> <match url="*api/dl/*" /> <action Type = "Rewrite" url = {2} R: "http://10.10.17.74:9100/" / > < / a > ruleCopy the code
other
It is customary to use configuration files to directly rewrite the configuration. In fact, IIS provides interface operations and can also test whether the configured rules are correct. Just for the record:
1. Click “URL Rewrite”
2, you can view the current website URL rules, can add, modify.
3, double click the added rule, click test mode, input the URL to test, click test will appear the result, can be used to check whether the rewrite URL and capture the same.
Problem three: Adding a website
Right click – add site, actually no problem, just record it.
Problem 4: Adding a media type
GLB /.gltf model files are visible locally, but not on the IIS server.
Because the MIME type needs to be configured:
Then look at the web.config file and find:
<staticContent> <mimeMap fileExtension=".glb" mimeType="application/glb" /> <mimeMap fileExtension=".gltf" MimeType =" Application/GLTF "/> <clientCache cacheControlMode="DisableCache" cacheControlMaxAge="3.00:00:00" /> </staticContent>Copy the code
OK.
Problem 5: Configuring the WS proxy and video call
The original configuration is as follows :(incorrect configuration)
<? The XML version = "1.0" encoding = "utf-8"? > <configuration> <system.webServer> <rewrite> <rules> <rule name="index"> <match url="^((? ! (api)|(wsProxy)).) *$" /> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> </conditions> <action type="Rewrite" url="/index.html" /> </rule> <rule name="api" patternSyntax="Wildcard"> <match url="*api/*" /> <action Type ="Rewrite" URL =" http://background service IP:PORT/{R:2}" /> </rule> <rule name=" videoAPI "patternSyntax="Wildcard"> <match /> </rule> <rule name="wsProxy" /> </rule name="wsProxy" PatternSyntax ="Wildcard"> <match URL ="*wsProxy/*" /> <action type="Rewrite" URL =" http://background service IP:PORT/{R:2}" /> </rule> </rules> </rewrite> <staticContent> <mimeMap fileExtension=".glb" mimeType="application/glb" /> <mimeMap fileExtension=".gltf" mimeType="application/gltf" /> <clientCache cacheControlMode="DisableCache" CacheControlMaxAge ="3.00:00:00" /> </staticContent> </system.webServer> </ Configuration >Copy the code
When the request path is
http://front-end IP address :PORT/ VideoAPI/background interface
The request will not match index, and then the API will be forwarded to the address of the API.
It doesn’t matter if videoAPI comes before API at this point.
<rule name="videoapi" patternSyntax="Wildcard"> <match url="*videoapi/*" /> <action type="Rewrite" Url =" http://background service IP:PORT/ videoAPI /{R:2}" /> </rule> <rule name=" API "patternSyntax="Wildcard"> <match URL ="* API /*" /> < action type = "Rewrite" url = "http:// backend service IP: PORT / {2} R:" / > < / a > ruleCopy the code
There are two correct configuration methods:
First, modify the code to replace the interception method of VedioAPI
Add stopProcessing=”true” to rule
Official note: docs.microsoft.com/zh-cn/excha…
The correct configuration is as follows:
<? The XML version = "1.0" encoding = "utf-8"? > <configuration> <system.webServer> <rewrite> <rules> <rule name="index" stopProcessing="true"> <match url="^((? ! (api)|(wsProxy)).) *$" /> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> </conditions> <action type="Rewrite" url="/index.html" /> </rule> <rule name="videoapi" patternSyntax="Wildcard" stopProcessing="true"> <match /> </rule> <rule name=" API "/> </rule name=" API" /> </rule name=" API" patternSyntax="Wildcard" stopProcessing="true"> <match url="*api/*" /> <action type="Rewrite" Url =" http://background service IP:PORT/{R:2}" /> </rule> <rule name="wsProxy" patternSyntax="Wildcard" stopProcessing="true"> <match WsProxy/url = "* *" / > < action type = "Rewrite" url = "http:// backend service IP: PORT / {2} R:" / > < / a > rule < / rules > < / Rewrite > < staticContent > <mimeMap fileExtension=".glb" mimeType="application/glb" /> <mimeMap fileExtension=".gltf" mimeType="application/gltf" /> <clientCache cacheControlMode="DisableCache" cacheControlMaxAge="3.00:00:00" /> </staticContent> </system.webServer> </configuration>Copy the code
Note:
The Configuration of VideoAPI should be in front of the API. When the videoAPI is successfully matched, the subsequent matching rules are not executed.