一招教你使用Node.js中iis部署运行node(附代码)
时间:2021-09-22
来源:互联网
标签:
今天PHP爱好者给大家带来如何使用Node.js中iis部署运行node方法教程,之前的文章《一文讲解Win10子系统安装与配置(分享)》中,给大家了解了Win10子系统安装与配置。下面本篇文章给大家介绍怎么使用Node.js中iis部署运行node,我们一起看看怎么做。希望对大家有所帮助。
从linux
迁移到windows server
,一言难尽。网上有说iis
已经支持node
了。IIS Node折腾了一下,没跑起来,估计兼容性不是那么好,索性放弃了。直接pm2
部署了。
IIS Node地址:https://github.com/tjanczuk/iisnode/wiki/iisnode-releases
安装了IIS UrlRewrite 地址:https://www.iis.net/downloads/microsoft/url-rewrite
在站点根目录创建web.config
, 内容如下
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}" redirectType="Found" />
</rule>
<rule name="root">
<match url="^(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="^chuchur.com$" />
</conditions>
<action type="Rewrite" url="http://127.0.0.1:7005/{R:1}" logRewrittenUrl="true" />
</rule>
<rule name="path">
<match url="^(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="^www.chuchur.com$" />
</conditions>
<action type="Rewrite" url="http://127.0.0.1:7005/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
其中有三条规则,第一条是https
的转发
第二条和第三条分别是把来源是主记录(chuchur.com
)和别名(www.chuchur.com
)的统统转发到node
端口上。
剩下的就是一个SPA
文档站点 (vue)
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="rest" stopProcessing="true">
<match url="^rest/(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="http://127.0.0.1:7005/rest/{R:1}" />
</rule>
<rule name="root">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/index.html" />
</rule>
</rules>
</rewrite>
<staticContent>
<mimeMap fileExtension=".woff2" mimeType="application/x-font-woff" />
</staticContent>
</system.webServer>
</configuration>
一起有 2 条规则,第一条是一个proxy
, 把/rest/
转发到node
端口的/rest/
上。第二条是vue
路由history
模式的地址Rewrite
阿里云是个坑货啊,买了2
年的CES
,到期了, 我就想着不续费,重新转到香港算了,这样我在香港搭个VPN
,又便宜,然后顺利的解决了翻墙的问题。
买了台Window Server2008
,一切准备就绪,什么都部署好了。结果没过两周,提示域名备案失效,个人认证失效,总之之前做的一切工作,都没用了。再次认证提示,服务器不在境内。香港不行。要我迁移回来。
说实在的香港的主机真的不怎么样,经常登录不上,vpn
也是时好时坏,基本也就是连不上,正好又出了政策,未备案的域名停止解析。这下网站基本就挂了。
于是又迁移回国内了。重新备案,重新个人认证一堆...
又从Window
切到Linux
。真的是很扯淡...
留个记录,怕哪天又要去折腾IIS
。
以上就是一招教你使用Node.js中iis部署运行node(附代码)的详细内容,更多请关注php爱好者其它相关文章!
-
hwinfo.dll是什么?hwinfo.dll文件下载及修复方法 时间:2025-09-25
-
searchindexer.exe是什么进程?searchindexer.exe应用程序错误怎么解决? 时间:2025-09-25
-
Windows远程桌面mstsc.exe是什么进程?mstsc.exe的使用和故障解决 时间:2025-09-25
-
Windows远程桌面rdpclip.exe是什么进程?rdpclip.exe无法启动? 时间:2025-09-25
-
C#中Random.Next()生成随机数函数详解 时间:2025-09-25
-
mscoree.dll是什么 mscoree.dll未能加载的原因及解决方法 时间:2025-09-25
今日更新
-
如何快速找回丢失的书签历史记录 简单几步轻松恢复
阅读:18
-
如何快速找回已卸载的抖音 简单几步恢复抖音App教程
阅读:18
-
电脑文件误删怎么恢复?3种方法快速找回回收站删除的文件
阅读:18
-
QQ密码找回教程:快速通过安全中心重置密码步骤详解
阅读:18
-
电脑无法连接宽带?5个快速解决方法轻松搞定
阅读:18
-
电脑提示找不到指定的模块?5种快速解决方法分享
阅读:18
-
揭秘堂堂眉毛梗的爆笑真相 原来全网都在模仿这个表情
阅读:18
-
Word文档自动生成目录详细教程 快速掌握目录排版技巧
阅读:18
-
电脑高手都在用的粘贴复制快捷键技巧大全
阅读:18
-
Word文档中快速绘制横线的3种实用方法 新手必学技巧
阅读:18