【问题标题】:two tpcs running on the same port, nginx and digitalocean两个 tpc 在同一个端口上运行,nginx 和 digitalocean
【发布时间】:2020-10-12 20:51:14
【问题描述】:

我正在数字海洋上部署我的 react 应用程序。我已按照本教程进行操作,一切顺利:https://www.youtube.com/watch?v=lN0oiYqenpA&ab_channel=RyanMichaelHirst

现在每当我访问我的 ip 或域名时,都会出现以下错误:404 not found.

每当我运行 nginx 的日志时,它都会说正在使用端口 80。因此我运行这个:

sudo netstat -pan | grep ":80"

tcp        0      0 159.203.87.191:80       52.84.150.39:31164      SYN_RECV    -
tcp        0      0 159.203.87.191:80       52.84.150.39:38386      SYN_RECV    -

我知道,这是一个内部错误,但我似乎找不到那个错误。 我有两件事在同一个端口上运行,一切都崩溃了。它昨天还在工作,我受到了 nginx 页面的欢迎。

这是我的服务器配置。(nginx)

upstream my_nodejs_upstream {
        # (this is the server's ip address)
        server x.x.x.x.;
        keepalive 64;
}

server {
        listen 80;
        listen [::]:80 ipv6only=on;

        # SSL configuration
        #
        # listen 443 ssl default_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 mmt-university;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_pass http://universitymmt.com/;
                proxy_set_header Host $http_host;
                proxy_set_header X-NginX-Proxy true;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_redirect off;
                proxy_read_timeout 240s;
        }

        # 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;
        #}
}

【问题讨论】:

  • 你的 nginx.conf 被设置为所谓的 reverse proxy 将传入的请求转发到http://universitymmt.com/ 哪个服务器运行它?它在哪里?如果它和你的 nginx 服务器是同一个 droplet,那么你就是在告诉 nginx 将你的请求转发给它自己。通常,当您在 nodejs 应用程序前面使用 nginx 时,您会有类似 proxy_pass http://localhost:3000; 这样的一行,
  • Digital Ocean 有很棒的教程。这与您的问题有关。 digitalocean.com/community/tutorials/…
  • @O.Jones 我有一个问题,说我在其他地方托管我的域,并且名称服务器指向我在 digitalocean 使用的那些。我已准备好部署该应用程序。我是否只是按照您在上面粘贴的链接进行操作?谢谢。

标签: node.js reactjs nginx digital-ocean


【解决方案1】:

连接处于 SYN_RECV 状态,因为内核收到了一个处于 LISTENING 模式的端口的 SYN 数据包,但另一端没有回复 ACK。

通过在服务器上运行捕获来检查服务器是否接收到 ACK。捕获是在客户端还是在服务器上?

此外,相当数量的 SYN-RECV 表明可能对主机执行了 SYN Flood 攻击。欲了解更多信息: https://www.cloudflare.com/learning/ddos/syn-flood-ddos-attack/

【讨论】:

  • 你好 Dinesh,服务器刚刚设置好,所以我很难相信任何形式的攻击都可能发生。您还有其他想法吗?
  • 您好 Tomas,您可以通过网络接口捕获数据包以详细查看流量
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-09-21
  • 1970-01-01
  • 2015-11-07
  • 2019-07-25
  • 2019-01-21
相关资源
最近更新 更多