AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1080833
Accepted
Philip Rego
Philip Rego
Asked: 2021-10-18 14:18:41 +0800 CST2021-10-18 14:18:41 +0800 CST 2021-10-18 14:18:41 +0800 CST

为什么是我的上游本地主机?在 Nginx 中获得 500 但没有应用程序错误。“连接到上游时没有实时上游”

  • 772

我正在按照本教程使用 Nginx 在 CentOS 上托管一个 React 应用程序。该网站在我运行时有效(200 响应)curl localhost:3000,但是当我尝试访问他的anthurie.com时,我收到 500 错误,并且此错误在/var/log/nginx/error.log

2021/10/17 17:56:16 [error] 5379#0: *5 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.1.1, server: anthurie.com, request: "GET / HTTP/1.1", upstream: "https://[::1]:3000/", host: "anthurie.com"
2021/10/17 17:56:16 [error] 5379#0: *5 SSL_do_handshake() failed (SSL: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol) while SSL handshaking to upstream, client: 192.168.1.1, server: anthurie.com, request: "GET / HTTP/1.1", upstream: "https://127.0.0.1:3000/", host: "anthurie.com"
2021/10/17 17:56:17 [error] 5379#0: *5 no live upstreams while connecting to upstream, client: 192.168.1.1, server: anthurie.com, request: "GET /favicon.ico HTTP/1.1", upstream: "https://localhost/favicon.ico", host: "anthurie.com", referrer: "https://anthurie.com/"
2021/10/17 18:01:01 [error] 5379#0: *9 no live upstreams while connecting to upstream, client: 192.168.1.1, server: anthurie.com, request: "GET / HTTP/1.1", upstream: "https://localhost/", host: "anthurie.com"
2021/10/17 18:01:02 [error] 5379#0: *9 no live upstreams while connecting to upstream, client: 192.168.1.1, server: anthurie.com, request: "GET /favicon.ico HTTP/1.1", upstream: "https://localhost/favicon.ico", host: "anthurie.com", referrer: "https://anthurie.com/"

不知道为什么upstream: "https://localhost/"应用程序大部分时间都在localhost:3000

/etc/systemd/system/anthurie.service

[Unit]
Description=Service run for reactjs application anthurie.com
After=network.target

[Service]
Type=simple
User=prego
Group=nginx
StandardOutput=syslog
StandardError=syslog
WorkingDirectory=/var/metaplex/js
Environment=NODE_ENV=’production’
ExecStart=/usr/bin/yarn start
Restart=always

[Install]
WantedBy=multi-user.target

nginx.conf

    server {
        proxy_read_timeout 10m;
        server_name anthurie.com;

        #a special location in case don't cache this file can be deleted
        location updater/serversettings.xml {
          expires -1;
          add_header 'Cache-Control' 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
        }

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        #The root/rest will be redirected
        location / {
            proxy_cache             hd_cache;
            proxy_set_header        X-Cache-Status $upstream_cache_status;
            proxy_cache_valid       200 1w;
            proxy_pass              https://localhost:3000;
            proxy_set_header        Host $http_host;
            proxy_buffers           16 8m;
            proxy_buffer_size       2m;
            gzip                    on;
            gzip_vary               on;
            gzip_comp_level         9;
            gzip_proxied            any;
        }
        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }


        listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/anthurie.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/anthurie.com/privkey.pem; # managed by Certbot
        include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
                                                                                                                                                                                    

我正在这台服务器上运行一个具有类似 nginx 配置的 Java 网站。不知道为什么当应用程序似乎运行良好时我会得到 500。

$ sudo systemctl status anthurie
● anthurie.service - Service run for reactjs application anthurie.com
   Loaded: loaded (/etc/systemd/system/anthurie.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2021-10-17 17:26:48 EDT; 49min ago
 Main PID: 4908 (node)
   CGroup: /system.slice/anthurie.service
           ├─4908 node /usr/share/yarn/bin/yarn.js start
           ├─4929 /usr/bin/node /var/metaplex/js/node_modules/.bin/cross-env CI=true lerna run start --scope @oyster/common --stream --parallel --scope web
           ├─4936 /usr/bin/node /var/metaplex/js/node_modules/.bin/lerna run start --scope @oyster/common --stream --parallel --scope web
           ├─4950 node /usr/share/yarn/bin/yarn.js run start
           ├─4961 node /usr/share/yarn/bin/yarn.js run start
           ├─4992 /usr/bin/node /var/metaplex/js/node_modules/.bin/npm-run-all --parallel watch watch-css watch-css-src
           ├─5010 /usr/bin/node /var/metaplex/js/packages/web/node_modules/.bin/next dev
           ├─5016 /usr/bin/node /usr/share/yarn/bin/yarn.js run watch
           ├─5017 /usr/bin/node /usr/share/yarn/bin/yarn.js run watch-css
           ├─5023 /usr/bin/node /usr/share/yarn/bin/yarn.js run watch-css-src
           ├─5061 /usr/bin/node /var/metaplex/js/node_modules/.bin/tsc --watch
           ├─5071 /usr/bin/node /home/prego/.yarn/bin/less-watch-compiler src/ src/
           ├─5079 /usr/bin/node /home/prego/.yarn/bin/less-watch-compiler src/ dist/lib/
           └─5255 /usr/bin/node /var/metaplex/js/node_modules/next/node_modules/jest-worker/build/workers/processChild.js

Oct 17 17:27:12 localhost.localdomain yarn[4908]: @oyster/common:         Property 'Bitpie' is missing in type 'import("/var/metaplex/js/node_modules/@solana/wallet-adapter-react/node_mo....WalletName'.
Oct 17 17:27:12 localhost.localdomain yarn[4908]: @oyster/common: src/contexts/wallet.tsx(230,3): error TS2344: Type '"publicKey" | "signTransaction" | "signAllTransactions"' does not sa...vents, any>'.
Oct 17 17:27:12 localhost.localdomain yarn[4908]: @oyster/common:   Type '"signTransaction"' is not assignable to type 'keyof WalletAdapterProps | keyof EventEmitter<WalletAdapterEvents, any>'.
Oct 17 17:27:12 localhost.localdomain yarn[4908]: @oyster/common: src/contracts/token.ts(106,23): error TS2571: Object is of type 'unknown'.
Oct 17 17:27:12 localhost.localdomain yarn[4908]: @oyster/common: 5:27:12 PM - Found 7 errors. Watching for file changes.
Oct 17 17:27:56 localhost.localdomain yarn[4908]: web: event - build page: /
Oct 17 17:27:56 localhost.localdomain yarn[4908]: web: wait  - compiling...
Oct 17 17:28:02 localhost.localdomain yarn[4908]: web: event - compiled successfully
Oct 17 17:29:04 localhost.localdomain yarn[4908]: web: wait  - compiling...
Oct 17 17:29:04 localhost.localdomain yarn[4908]: web: event - compiled successfully
nginx centos7
  • 1 1 个回答
  • 852 Views

1 个回答

  • Voted
  1. Best Answer
    Alexander Tarasov
    2021-10-18T14:39:11+08:002021-10-18T14:39:11+08:00

    尝试在这里https替换http:

    proxy_pass https://localhost:3000;
    

    并重新加载 nginx。你说这curl localhost:3000行得通,并且省略 curl 的协议假设http://. 很可能,您的后端应用程序不支持 HTTPS(或至少在此端口不支持)。

    • 1

相关问题

  • Gzip 与反向代理缓存

  • nginx 作为代理的行为

  • Nginx 学习资源 [关闭]

  • 提供 70,000 个静态文件 (jpg) 的最佳方式?

  • 在 Apache、LightTPD 和 Nginx Web 服务器上提供 PHP 5.x 应用程序的现状?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

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

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve