前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >IIS 部署node

IIS 部署node

作者头像
chuchur
发布2022-10-25 14:36:25
2.3K0
发布2022-10-25 14:36:25
举报
文章被收录于专栏:禅境花园

linux 迁移到 windows server,一言难尽. 网上有说 iis 已经支持 node 了. IIS Node

折腾了一下, 没跑起来,估计兼容性不是那么好,索性放弃了. 直接 pm2 部署了.

安装了 IIS UrlRewrite

在站点根目录创建 web.config, 内容如下

代码语言:javascript
复制
<?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)

代码语言:javascript
复制
<?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,到期了, 我就想着不续费,重新转到中国香港算了,这样我在香港搭个 V** ,又便宜,然后顺利的解决了翻墙的问题.

买了台 Window Server2008 ,一切准备就绪,什么都部署好了. 结果没过两周 ,提示域名备案失效,个人认证失效,总之之前做的一切工作, 都没用了. 再次认证提示,服务器不在境内.香港不行. 要我迁移回来.

说实在的中国香港的主机真的不怎么样, 经常登录不上, v** 也是时好时坏,基本也就是连不上, 正好又出了政策,未备案的域名停止解析. 这下网站基本就挂了.

于是又迁移回国内了.重新备案,重新个人认证一堆... 又从 Window 切到Linux. 真的是很扯淡... 留个记录,怕哪天又要去折腾 IIS.

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019/01/25 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
ICP备案
在中华人民共和国境内从事互联网信息服务的网站或APP主办者,应当依法履行备案手续。腾讯云为您提供高效便捷的 ICP 备案服务。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档