2

I have spent hours trying to come up with a solution and read a lot of web socket solution with a nginx, still no luck

I have a websocket application containerised with docker and running on ec2 instances using ecs. my websocket need to be able to autoscale when needed.

I have tested connectivity with Classic elb and all works well but it doesn't support websocket protocol.

Down to ALB and NLB

ALB only allows HTTP and HTTPS protocol and support websockets and i am unsure of how to implement that to achieve accessing my websocket over the WSS protocol also target group heath checks fails.

NLB works well as it allows TCP protocol but the only issue is that it doesn't terminate SSL.

The only solution was to install the SSL cert on the EC2 and setup nginx reverse proxy to the docker container. but i have had no joys with that as i have had no experience with Nginx i might not have the right config. but i am still not able to connect to websocket over wss. Any assistance welcomed

My main objective is connecting to websocket over wss.

worker_processes 1;

events { worker_connections 1024; }

http {

sendfile on;

upstream docker-nginx {
    server nginx:443;
    ssl_certificate /etc/ssl/private/example.chained.crt;
    ssl_certificate_key /etc/ssl/private/example.key;
    ssl_session_timeout 1d;
    ssl_session_cache shared:SSL:50m;
    ssl_session_tickets off;
}

upstream localhost {
    server apache:443;
}

server {
    listen 443;

    location / {
        proxy_pass         http://localhost;
        proxy_redirect     off;
        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-Host $server_name;
    }
}

server {
    listen 443;

    location / {
        proxy_pass         http://example.com;
        proxy_redirect     off;
        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-Host $server_name;
    }
  }

}
Robert Moskal
  • 21,737
  • 8
  • 62
  • 86
segs
  • 39
  • 3

1 Answers1

-3

This was resolved by using ALB.

segs
  • 39
  • 3