【问题标题】:NGINX With React BuildNGINX 与 React 构建
【发布时间】:2020-05-09 19:42:16
【问题描述】:

我将我的 React 构建文件放入:root/website.com/site/public

我的/etc/nginx/sites-available/default

server {
    listen 80 default_server;
    root /root/website.com/site/public/;
    server_name 00.000.00.000; 
    index index.html index.htm;
    location / {
            try_files $uri $uri/ =404;
    }
}

当我访问我的 IP 地址时,我收到了一个错误的网关错误。我是否需要运行npm start 才能显示我的index.html

由于某种原因,当我运行npm start 时,它会在/site/src 中搜索index.html,然后如果我将public 的名称更改为src,它会在site/public 中搜索。

【问题讨论】:

标签: reactjs nginx


【解决方案1】:

显然 nginx 无法使用 /root/website.com/site/public。将其更改为典型的 /var/www/website/site/public 并将我的构建文件移到那里并且它工作。

【讨论】:

    猜你喜欢
    • 2019-02-10
    • 2022-01-22
    • 1970-01-01
    • 2020-07-23
    • 2019-12-26
    • 2018-11-23
    • 1970-01-01
    • 1970-01-01
    • 2021-03-13
    相关资源
    最近更新 更多