Azure nodejs подкаталог настраиваемого домена веб-приложения в другое azure веб-приложение (блог) - PullRequest
0 голосов
/ 31 марта 2020

У меня есть простое Node.js Webapp с пользовательским доменом, например: domain.com.
Я создал еще одно azure cloudapp из bitnami и сопоставил его с blog.domain.com

Теперь я хотел бы иметь путь к блогу domain.com/blog, который должен обслуживать блог с blog.domain.com

. В процессе исследования я добавил маршрут к блогу на сервере . js и правило в моем web.config
, но оно не работает.

Сервер. js

const express = require('express');
const port = process.env.PORT || 1337;
const app = express();
const path = require('path');
const router = express.Router();

router.get('/',(req,res) => {
  res.sendFile(path.join(__dirname +  '/public/index.html'));
});

router.get('/blog',(req,res) => {
  res.sendFile(path.join(__dirname + '/public/blog.html'));
});

app.use(express.static(__dirname + '/public'));
app.use('/', router);

app.listen(port);

Web.config

<configuration>
  <system.webServer>
    <webSocket enabled="false" />
    <handlers>
      <!-- Indicates that the server.js file is a node.js site to be handled by the iisnode module -->
      <add name="iisnode" path="server.js" verb="*" modules="iisnode"/>
    </handlers>
    <rewrite>
      <rules>
        <!-- Do not interfere with requests for node-inspector debugging -->
        <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
          <match url="^server.js\/debug[\/]?" />
        </rule>

        <!-- 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="server.js"/>
        </rule> -->
        <rule name="blogRedirect" stopProcessing="true" enabled="true"> 
            <match url="^blog" />
            <conditions>
                <add input="{HTTP_HOST}"/>
            </conditions>
            <action type="Redirect" url="https://mathan.azurewebsites.net/hello" />
        </rule>
      </rules>
    </rewrite>

    <!-- 'bin' directory has no special meaning in node.js and apps can be placed in it -->
    <security>
      <requestFiltering>
        <hiddenSegments>
          <remove segment="bin"/>
        </hiddenSegments>
      </requestFiltering>
    </security>

    <httpErrors existingResponse="PassThrough" />
  </system.webServer>
</configuration>

Может кто-нибудь подсказать мне, что не так с тем, что я сделал?

...