错误:在天蓝色服务器上侦听EACCES 0.0.0.0:80节点(Windows server 2012 r2)

时间:2016-03-29 19:20:08

标签: node.js windows azure

我停止了万维网发布服务并将启动类型更改为已禁用,并以管理员身份启动以启动网站但收到了EACCES。

这是权限错误吗?我已经读过在linux / unix上用sudo运行这个网站修复了这个问题,但是在Windows上呢?

编辑:我最终使用iisnode,因为我无法解决端口80上的EACCES错误。以下是我通过iisnode模块在iis上运行节点服务器的步骤:

*安装iisnode(您想要的任何地方);
*为iss安装'URL Rewrite'插件;
*创建新网站;
*使用以下命令创建web.config文件:

  1. 服务器文件上iisnode的处理程序映射,包含服务器文件的路径;
  2. 重写url规则,任何对url的请求都转到服务器文件;
  3. 调试和日志记录(带有日志文件目标路径)设置为true;
  4. (请在本文底部找到一个示例web.config文件)

    *授予SERVER / IIS_IUSRS对站点iis中找到的目录/虚拟目录的写权限;
    *创建本地绑定;
    *使用*:80创建外部绑定作为端口;
    *确保节点的http侦听器设置为侦听process.env.PORT,因为iisnode会将此环境变量设置为80以用于http请求;

    根文件夹中的示例web.config文件,并假设节点服务器(在本例中它将被称为app.js)也位于根文件夹中。

    <configuration>
      <system.webServer>
                 <!--Tells iis that app.js is to be handled by iisnode module-->
        <handlers>
            <add name="iisnode" path="app.js" verb="*" modules="iisnode" /> 
        </handlers>
            <!--Url rewrite rule that anything coming to any url of within site goes through app.js-->
        <rewrite>
            <rules>
                <rule name="toNode">
                    <match url="/*"/>
                    <action type="Rewrite" url="app.js"/>
                </rule>
            </rules>
        </rewrite>
    
      </system.webServer>
    </configuration>
    

    编辑:在大多数情况下,我遵循了本教程: https://www.youtube.com/watch?v=JUYCDnqR8p0

3 个答案:

答案 0 :(得分:1)

如果您想在端口node上运行80应用,则必须使用sudo特权帐户运行该应用。

对于Windows,可能重启iis节点可以解决问题。

run node.js webbapp on 80 port on windows

答案 1 :(得分:0)

我想通过使用库中的图像Windows Server 2012 R2 DataCenter创建Azure VM来重现此问题,但是节点应用程序无法在端口80上运行。

根据我的经验,您可以尝试一些步骤来解决问题。

  1. 选择Command Prompt并右键单击以选择Run as administrator选项,以便以管理员身份启动cmd以运行节点或其他人。
  2. 命令netstat -ao显示所有侦听端口及其PID,然后找到本地地址0.0.0.0:80和命令taskkill /PID <PID> /F之一,以强制终止在端口80上运行的进程。
  3. 尝试再次命令node app.js

答案 2 :(得分:0)

您还可以从Azure CLI生成Node.js Azure Webapp。

  1. 使用NPM安装Azure CLI:

    $('#add_item').on('click',function(){ $('#myModal').modal({ backdrop: 'static', keyboard: false, $(this).hide(); // add hide function inside of modal $('#add_item').hover(function() { // add hover event handler && function inside of modal $(this).text('new text'); }); }); $('.class').hide(); // add hide function outside of modal $('.class').hover(function(){ // add hover event handler && function outside of modal $('#add_item'). }); });

  2. 登录您的azure帐户:

    c:\> npm install azure-cli -g

  3. 将模式更改为 asm

    c:\> azure login

  4. 从您当地的git存储库中创建一个azure webapp(名为 yoursite ):

    c:\> azure config mode asm

  5. 这将生成在c:\git\yoursite> azure site create --git yoursite文件中添加所有必要设置。

    1. 使用git提交:

      issnode.yml

    2. 将修改推送到azure服务器:

      c:\git\yoursite> git add . && git commit -m "initial commit"

    3. Azure将添加节点依赖项并在端口80上运行您的站点。

相关问题