0

我需要什么配置文件来启动 Remix 应用程序?它没有index.html文件

重现步骤(https://remix.run/docs/en/v1/guides/deployment):

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
cd my-remix-app
npm run build

我们必须目录:public, build

下一步在website.com使用时展示它是nginx什么?

4

2 回答 2

1

最简单的方法是选择 Remix App Server(内部使用 Express)或 Express,然后 runremix build构建用于生产的应用程序并 runnpm start运行服务器。

之后,它是一个普通的 Node.js 服务器,因此您可以将 NGINX 配置为将端口 80 和 443 上的请求转发到在另一个端口(默认为 3000)上运行的 Remix 应用程序。这是正常的 Node.js + NGINX 部署,没有特定于 Remix。

于 2021-12-15T21:46:04.423 回答
0

对,您应该先构建并启动节点应用程序。

这是一个例子:

server {
  listen 80;
  listen 443 ssl http2;
  server_name  example.com;

  ssl_certificate /home/example.com/ssl.crt;
  ssl_certificate_key /home/example.com/ssl.key;
  ssl_session_cache shared:le_nginx_SSL:1m;
  ssl_session_timeout 1440m;

  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  ssl_prefer_server_ciphers on;

  ssl_ciphers "ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS";

#  add_header Access-Control-Allow-Origin "*";
  add_header Strict-Transport-Security "max-age=31536000;";
  
  access_log off;
#  error_log /home/logs/error.nginx.log crit;

  location / {
    if ($http_user_agent = Mozilla/4.0){
      return 503;
    }
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;
    proxy_set_header X-NginX-Proxy true;
    proxy_pass http://127.0.0.1:3000/;
    proxy_redirect off;
  }
}
于 2022-01-09T05:48:31.393 回答