1

为了测试,我将Playground添​​加到项目中。在 http://localhost:5000/playground 的情况下,一切正常并连接到Spring Boot后端并收听通知 在此处输入图像描述 现在,在Elastic Beanstalk中,我无法获取订阅模式。(通知)

在此处输入图像描述

为了制作wss,我将这两行添加到 .platform\nginx\conf.d\https.conf
([根据此 url] 在此处输入链接描述 graphql 订阅无法连接到弹性 beanstalk 的 websocket 端点

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

所以结果是

# .platform\nginx\conf.d\https.conf

server {
    listen       443;
    server_name  localhost;

    ssl                  on;
    ssl_certificate      /etc/letsencrypt/live/XXXXXX.us-east-1.elasticbeanstalk.com/fullchain.pem;
    ssl_certificate_key  /etc/letsencrypt/live/XXXXXX.us-east-1.elasticbeanstalk.com/privkey.pem;

    ssl_session_timeout  5m;

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

    location / {
        proxy_pass  http://localhost:5000;
        proxy_set_header        Upgrade         $http_upgrade;                    // HERE
        proxy_set_header        Connection      "upgrade";                        // And HERE
        proxy_http_version 1.1;
        proxy_set_header        Host            $host;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header        X-Forwarded-Proto https;
    }
  
}
# .platform\nginx\conf.d\elasticbeanstalk\00_application.conf

location / {
    if ($http_x_forwarded_proto = "http") {
        set $redirect "https";
    }
    if ($http_x_forwarded_proto = "ws") {
        set $redirect "wss";
    }
    if ($http_user_agent ~* "ELB-HealthChecker") {
      set $redirect "nope";
    }
    if ($redirect = "https") {
      return 301 https://$host$request_uri;
    }
    if ($redirect = "wss") {
      return 301 wss://$host$request_uri;
    }

    proxy_pass          http://127.0.0.1:5000;
    proxy_http_version  1.1;

    proxy_set_header    Connection          $connection_upgrade;
    proxy_set_header    Upgrade             $http_upgrade;
    proxy_set_header    Host                $host;
    proxy_set_header    X-Real-IP           $remote_addr;
    proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
}

如何在.platform\nginx\conf.d中设置文件来处理这个问题?

4

0 回答 0