iis服务器,配置node.js

一.需要的插件

//遇到不能下载的情况可以在网盘中提取
网盘:https://pan.baidu.com/s/1q1GlHa_e0W-kQNnVY7rLaQ 
提取码:hwf4 
  • 下载url重写 在iis的web平台安装程序中搜索并安装

二.把入口文件 改成index.js

1.项目根目录新建index.js 复制bin/www内的内容到index.js  *注意index.js引入的文件路径*
// 2.并在package.json 中修改 
 "scripts": {
    "dev": "node-dev index.js"
  },

三.设置web.config

<configuration>
  <system.webServer>

    <!-- indicates that the hello.js file is a node.js application 
    to be handled by the iisnode module -->

    <handlers>
        <add name="iisnode" path="index.js" verb="*" modules="iisnode" resourceType="Unspecified" requireAccess="Script" preCondition="bitness64" />
    </handlers>
    
    <rewrite>
            <rules>
                <rule name="all">
                    <match url="/*" />
                    <action type="Rewrite" url="index.js" />
                </rule>
            </rules>
    </rewrite>    
    
    <iisnode 
        node_env="%node_env%" 
        nodeProcessCountPerApplication="1" 
        maxConcurrentRequestsPerProcess="1024" 
        maxNamedPipeConnectionRetry="100" 
        namedPipeConnectionRetryDelay="250" 
        maxNamedPipeConnectionPoolSize="512" 
        maxNamedPipePooledConnectionAge="30000" 
        asyncCompletionThreadCount="0" 
        initialRequestBufferSize="4096" 
        maxRequestBufferSize="65536" 
        watchedFiles="*.js;node_modules\*;routes\*.js;views\*.jade" 
        uncFileChangesPollingInterval="5000" 
        gracefulShutdownTimeout="60000" 
        loggingEnabled="true" 
        logDirectory="iisnode" 
        debuggingEnabled="true" 
        debugHeaderEnabled="false" 
        debuggerPortRange="5058-6058" 
        debuggerPathSegment="debug" 
        maxLogFileSizeInKB="128" 
        maxTotalLogFileSizeInKB="1024" 
        maxLogFiles="20" 
        devErrorsEnabled="true" 
        flushResponse="false" 
        enableXFF="false" 
        configOverrides="iisnode.yml" 
        nodeProcessCommandLine="C:\Program Files\nodejs\node.exe" 
        promoteServerVars="REMOTE_ADDR" />
        
        <defaultDocument>
            <files>
                <add value="index.js" />
            </files>
        </defaultDocument>

  </system.webServer>
</configuration>

四.如果遇到下面的问题

iisnode encountered an error when processing the reques. 
HRESULT: 0x2 HTTP. 
status: 500
You are receiving this HTTP 200 response because system.webServer/iisnode/@devErrorsEnabled configuration setting is 'true'.
...


//解决方法
1.找到项目的根目录 右击鼠标 进入属性页面
2.点击 *安全* 按钮,点击编辑按钮 
3.点击添加按钮,添加一个自定义组或用户名
4.选择自定义的组或用户名,选择所有权限点击确定
权限设置.png

五.新建网站

具体内容移步: 详细过程

六.通过花生壳内网传透,设置外网访问

*(1)设置防火墙的入栈规则

  • 1.首先打开控制面板中的防火墙,点击高级设置


    高级设置.png
  • 2.进入高级设置后,点击入栈规则,在操作一栏点击新建规则
入栈规则.png
  • 3.在规则类型中选择 端口
    规则类型.png
  • 4 协议和端口分别选择 TCP和 设置的端口号


    协议和端口.png
  • 5 操作及配置文件 :默认或者自定义
  • 6 名称: 建议设置成和项目有关的,方便查找和删除

(2)花生壳内网映射

  • 1.类型选择http,外网域名自带两个(可创建一个),外网端口随机,内网本机ip地址,端口自定义的端口


    内网映射.png
  • 2.访问外网接口


    访问.png
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容