部署前preSS 4.x版应用程序到Windows Azure [英] Deploying Express 4.x app to Windows Azure

查看:149
本文介绍了部署前preSS 4.x版应用程序到Windows Azure的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

防爆preSS的新版本的模块从服务器文件隔开。现在住在 / bin中/ WWW ,我会preFER保持这个约定如果可能的话。

The new version of Express separates the modules from the "server" file. It now lives in /bin/www and I'd prefer to keep this convention if possible.

的package.json 文件,开始的剧本明确指出正确的地方,但是这看似Azure的忽略。

In the package.json file, the "start" script clearly points to the right place, but this is seemingly ignored by Azure.

如何部署,而无需在根目录下的 server.js 文件中的前preSS 4.x的应用程序?所有我需要做的就是让它自动调用节点 ./斌/ WWW 而不是节点 server.js 。是否有另一种根的配置文件,我可以添加特定的云主机(Azure的?)这是我得到的Heroku在这个工作等。

How do I deploy an Express 4.x app without having a server.js file in the root directory? All I need to do is make it automatically call node ./bin/www instead of node server.js. Is there another root configuration file I can add specific to the cloud host (Azure?) This is how I got this working in Heroku, etc.

推荐答案

在Azure团队自内部固定这一点。新部署的前preSS 4应用程序应该工作在Azure上的网站就好了,没有任何其他更改。

updated answer

The Azure team has since fixed this internally. A newly deployed express 4 app should work just fine on Azure Websites without any additional changes.

我将与TL启动;博士。在应用程序的根目录下创建一个web.config文件,并使用该XML。

I'll start with the tl;dr. Create a web.config file in the root of your application and use this xml.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>

    <!-- 
      By default IIS will block requests going to the bin directory for security reasons. 
      We need to disable this since that's where Express has put the application entry point. 
    -->
    <security>
      <requestFiltering>
        <hiddenSegments>
          <remove segment="bin" />
        </hiddenSegments>
      </requestFiltering>
    </security>

    <handlers>
      <!-- Indicates that the www file is a node.js entry point -->
      <add name="iisnode" path="/bin/www" verb="*" modules="iisnode"/>
    </handlers>
    <rewrite>
      <rules>
        <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
          <match url="^bin\/www\/debug[\/]?" />
        </rule>

        <!-- 
          First we consider whether the incoming URL matches a physical file in the /public folder. 
          This means IIS will handle your static resources, and you don't have to use express.static 
        -->
        <rule name="StaticContent">
          <action type="Rewrite" url="public{REQUEST_URI}"/>
        </rule>

        <!-- All other URLs are mapped to the node.js entry point -->
        <rule name="DynamicContent">
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
          </conditions>
          <action type="Rewrite" url="/bin/www"/>
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

这是一个有点乱,并花了一段时间来追查。我真的希望它是足够聪明,看的package.json,但是这是我们必须面对现在。通常天青确定它是否是通过检查一个app.js或server.js文件节点的应用程序。如果找到该文件,它会自动创建非常类似于上面什么是web.config文件。在这种情况下,将检测app.js,但不同于其它节点的应用99%,这是不实际的入口点。我们所要做的就是改变如上所示的入口点为/ bin / WWW。

This is a bit of a mess and took a while to track down. I really wish it was smart enough to look at package.json, but this is what we have to deal with for now. Normally Azure determine if it is a Node application by checking for an app.js or server.js file. If it finds that file, it will automatically create a web.config file very similar to what is above. In this case, it will detect app.js, but unlike 99% of other node applications, that's not actually the entry point. What we have to do is change the entry point to /bin/www like shown above.

我们遇到的另一个问题是,通过默认的IIS块请求,出于安全原因的bin文件夹。我们可以重命名前preSS bin文件夹,或者告诉IIS克服它。这就是XML文件的hiddenSegments部分是

The other issue we run into is that by default IIS blocks requests to the bin folder for security reasons. We can either rename the express bin folder, or tell IIS to get over it. That's what the hiddenSegments part of the xml file is for.

这篇关于部署前preSS 4.x版应用程序到Windows Azure的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆