RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / 问题 / 1435573
Accepted
Денис Беспалов
Денис Беспалов
Asked:2022-08-03 03:29:25 +0000 UTC2022-08-03 03:29:25 +0000 UTC 2022-08-03 03:29:25 +0000 UTC

VPS 服务器给出 404. React

  • 772

我在这个问题上完全是菜鸟,但我真的很想部署我的工作。

MERN 堆栈中有一个应用程序。(蒙戈,快递,反应,节点)

我使用 nginx 使用简短指令设置了 ubuntu 上的 VPS 服务器:
https ://github.com/yestellar/deploy-node-nginx-ssl

服务器由Jino 提供。

在根目录中,我有 2 个文件夹:客户端和服务器,我实际上在其中克隆了必要的存储库。在服务器文件夹中,我克隆了节点服务器并启动它,控制台中显示一条消息,说明一切正常。然后,使用 pm2,我使用上面链接中文章中的命令启动了客户端。

NODE_ENV=production pm2 start npm --name strapi -- run start # Запустить в режиме продакшн npm run start скрипт и назвать "strapi"

状态显示“正常”

一般来说,在任何地方,所有状态都可以:nginx、node、npm、mongo……但该站点给出了 404。

我尝试了不同的设置和代理,/etc/nginx/sites-available/default 但它不起作用

怎么修?我将非常感谢任何信息。

这是代码/etc/nginx/sites-available/default :

PS带有return的行被注释掉了,因为 无休止的重定向,首先您需要至少使 http 工作,然后我将处理 https。

server {
   # listen [::]:443 ssl default_server;
    #
    # Note: You should disable gzip for SSL traffic.
    # See: https://bugs.debian.org/773332
    #
    # Read up on ssl_ciphers to ensure a secure configuration.
    # See: https://bugs.debian.org/765782
    #
    # Self signed certs generated by the ssl-cert package
    # Don't use them in a production server!
    #
    # include snippets/snakeoil.conf;

    root /var/www/html;

    # Add index.php to the list if you are using PHP
    index index.html index.htm index.nginx-debian.html;

    server_name site-name.ru  www.site-name.ru;

location / {
    proxy_pass http://localhost:3000;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
        proxy_redirect off;
}

        # pass PHP scripts to FastCGI server
        #
        #location ~ \.php$ {
        #       include snippets/fastcgi-php.conf;
        #
        #       # With php-fpm (or other unix sockets):
        #       fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
        #       # With php-cgi (or other tcp sockets):

            #       fastcgi_pass 127.0.0.1:9000;
            #}
    
            # deny access to .htaccess files, if Apache's document root
            # concurs with nginx's one
            #
            #location ~ /\.ht {
            #       deny all;
            #}
    
        listen [::]:443 ssl ipv6only=on; # managed by Certbot
        listen 443 ssl; # managed by Certbot
        ssl_certificate /etc/letsencrypt/live/site-name.ru/fullchain.pem; # man>
        ssl_certificate_key /etc/letsencrypt/live/site-name.ru/privkey.pem; # m>
        include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
    
    
    }
    
    #
    #server {
    #       listen 80;
    #       listen [::]:80;
    #
    #       server_name example.com;
    #
    #       root /var/www/example.com;
    #       index index.html;
    #
    #       location / {
    #               try_files $uri $uri/ =404;
    #       }
    #}
    
    server {
        if ($host = www.site-name.ru) {
           # return 301 https://$host$request_uri;
        } # managed by Certbot
    
    
        if ($host = site-name.ru) {
            #return 301 https://$host$request_uri;
        } # managed by Certbot
    
    
            listen 80 default_server;
            listen [::]:80 default_server;
    
            server_name site-name.ru www.site-name.ru;
        return 404; # managed by Certbot
    }
reactjs node.js
  • 1 1 个回答
  • 26 Views

1 个回答

  • Voted
  1. Best Answer
    Денис Беспалов
    2022-08-03T04:25:08Z2022-08-03T04:25:08Z

    问题解决了。我在这里的 nginx 文档中找到了我的问题的答案:http: //nginx.org/ru/docs/beginners_guide.html

    正如你在我的文件中看到的/etc/nginx/sites-available/default

    有表格的块server { ... }。

    在每个这样的块中都有一个端口监听器listen,以及location

    问题是在server标准所在的第二个街区,listen 80没有标明位置。我一标记,服务器就开始发出我的申请

    • 1

相关问题

  • 如果图像在道具中,如何使背景图像做出反应?

  • 项目未显示

  • 引发错误:InvalidTokenError: Invalid token specified: Cannot read property 'replace' of undefined

  • 如何在没有 node.js 的情况下运行 react.js 应用程序

  • 如何从 React Native 中的导航堆栈中清除上一个屏幕?

  • 为什么渲染后会触发 Click 事件?

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5