如何将React Remix框架部署到Windows Server 2022上的IIS?

huangapple go评论68阅读模式
英文:

How to deploy react Remix framework to IIS on windows server 2022?

问题

我在REMIX框架上开发了一个应用程序。但我不知道如何在Windows Server 2022上的IIS服务器上发布它。
应该选择哪些选项来配置IIS。

npx create-remix@latest
? 您想在哪里创建您的应用程序? (./my-remix-app)
? 您想要部署到哪里?如果不确定,请选择Remix,更改部署目标很容易。 (使用箭头键)
❯ Remix应用程序服务器
? TypeScript还是JavaScript? (使用箭头键)
❯ TypeScript

英文:

I developed an App on REMIX framework. But ı do not know how will i publish it on IIS server on Windows Server 2022.
Which opitons should selected for IIS.

 npx create-remix@latest
 ? Where would you like to create your app? (./my-remix-app)
 ? Where do you want to deploy? Choose Remix if you're unsure, it's easy to change deployment targets. (Use arrow keys)
❯ Remix App Server
? TypeScript or JavaScript? (Use arrow keys)
❯ TypeScript

答案1

得分: 1

Remix 在 Windows 上运行时需要 Node.js。您应该选择 Remix App Server

关于如何在 IIS 上设置反向代理有很多在线文章。您希望代理到默认情况下运行在 localhost:3000 上的 RAS。

https://www.google.com/search?q=iis+nodejs+reverse+proxy

英文:

Remix requires Node.js when running on Windows. You should select Remix App Server.

There are plenty of articles online on how to set up a reverse proxy on IIS. You want to proxy to RAS running on localhost:3000 (by default).

https://www.google.com/search?q=iis+nodejs+reverse+proxy

答案2

得分: 1

React Remix框架的最佳方式是选择Remix App Server,然后运行 remix build 来构建应用程序以供生产使用,然后运行 npm start 来运行服务器。在执行上述操作后,请将其视为普通的Node.js服务器,并遵循传统方式 - 使用反向代理在Windows IIS上部署Node.js应用程序。

  1. 在Windows Server上安装Node.js
  2. 部署和测试Node.js应用程序
  3. 为我们的Node.js应用程序在IIS上创建一个网站
  4. 在IIS上配置反向代理
英文:

The best way for the React Remix framework is to select Remix App Server, then run remix build to build the app for production, and run npm start to run the server. After performing the above operations, please treat it as a normal Node.js server, and follow the Conventional Way - deploying a node.js application on windows IIS using a reverse proxy.

  1. Install Node.js on Windows Server
  2. Deploy and test Node.js applications
  3. Create a website for our Node.js application on IIS
  4. Configure Reverse Proxy on IIS

答案3

得分: 0

感谢提供的答案,为我提供了找到解决方案的方法。

  1. 在 Windows 服务器上安装 Node.js
  2. 在 Windows 服务器上安装 IIS Node
  3. 在 Windows 服务器上安装 URL Rewrite
  4. 将所有文件上传到您的网站文件夹中,位于 wwwroot 下,除了 .cache、build、public/build 和 node_modules 文件夹(我们将在服务器上安装它们)。
  5. 在网站文件夹下,打开命令提示符并输入以下命令:npm install
  6. 输入命令:npm run dev
  7. 在网站的主路径下创建一个 web.config 文件,其中包含以下代码:
<?xml version="1.0" encoding="utf-8"?>
<configuration> 
  <system.webServer>
    <iisnode loggingEnabled="false" nodeProcessCommandLine="C:\Program Files\nodejs\node.exe" />        
    <handlers>
      <add name="iisnode" path="/build/index.js" verb="*" modules="iisnode" />
    </handlers>  
    <security>
      <requestFiltering>
        <hiddenSegments>
          <add segment="node_modules" />
          <add segment="iisnode" />
        </hiddenSegments>
      </requestFiltering>
    </security>
    <rewrite>
      <rules>
        <rule name="ReverseProxyInboundRule1" stopProcessing="true">
          <match url="(.*)" />
          <action type="Rewrite" url="http://localhost:3000/{R:1}" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer> 
</configuration>
英文:

Thanks for answers which showed me a way for found a solition.

  1. Install Node.js on Windows Server .

  2. Install IIS Node on Windows Server.

  3. Install URL Rewrite on Windows Server.

  4. Upload all files to under your web site folder on wwwroot except .cache,build,public/build,node_modules folders.(we will install them on server.)

  5. Under web site folder, type command on cmd npm install

  6. Type command npm run dev

  7. Create a web.config file main path of web site. Codes are :

    &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
    &lt;configuration&gt; 
    &lt;system.webServer&gt;
    &lt;iisnode loggingEnabled=&quot;false&quot; nodeProcessCommandLine=&quot;C:\Program Files\nodejs\node.exe&quot; /&gt;        
    &lt;handlers&gt;
    &lt;add name=&quot;iisnode&quot; path=&quot;/build/index.js&quot; verb=&quot;*&quot; modules=&quot;iisnode&quot; /&gt;
    &lt;/handlers&gt;  
    &lt;security&gt;
    &lt;requestFiltering&gt;
     &lt;hiddenSegments&gt;
       &lt;add segment=&quot;node_modules&quot; /&gt;
       &lt;add segment=&quot;iisnode&quot; /&gt;
     &lt;/hiddenSegments&gt;
     &lt;/requestFiltering&gt;
     &lt;/security&gt;
     &lt;rewrite&gt;
        &lt;rules&gt;
            &lt;rule name=&quot;ReverseProxyInboundRule1&quot; stopProcessing=&quot;true&quot;&gt;
                &lt;match url=&quot;(.*)&quot; /&gt;
                &lt;action type=&quot;Rewrite&quot; url=&quot;http://localhost:3000/{R:1}&quot; /&gt;
            &lt;/rule&gt;
        &lt;/rules&gt;
    &lt;/rewrite&gt;
    &lt;/system.webServer&gt; 
    &lt;/configuration&gt;
    

huangapple
  • 本文由 发表于 2023年1月8日 23:58:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/75049232.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定