Codshark11
Codshark11

Reputation: 87

How to get GraphQL schema of a subscription from Spring Boot backend in AWS Elastic Beanstalk

For testing, I added Playground into the project. In http://localhost:5000/playground case, everything is OK and connected to the Spring Boot backend and listening to notifications enter image description here Now, in Elastic Beanstalk, I cannot fetch subscription schema. (notifications)

enter image description here

To make the wss, I added these 2 lines to .platform\nginx\conf.d\https.conf
([according to this url] enter link description here graphql subscription Could not connect to websocket endpoint at elastic beanstalk)

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

so the result is

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

How do I have to set files in .platform\nginx\conf.d to handle this issue?

Upvotes: 1

Views: 188

Answers (0)

Related Questions