Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSS support #844

Open
1 task done
VinnieCool opened this issue Aug 5, 2023 · 2 comments
Open
1 task done

WSS support #844

VinnieCool opened this issue Aug 5, 2023 · 2 comments

Comments

@VinnieCool
Copy link

Is there an existing feature request for this?

  • I have searched the existing feature requests

Is your feature request related to a problem? Please describe.

AWS allows only wss and not ws. WSS is not just secure, it is better because the ISPs and gateways won't block wss traffic as they don't see it

Describe the solution that you would like.

Provide wss support in gorilla-websocket implementation, or guide/point me so I can help add

Describe alternatives you have considered.

No response

Anything else?

No response

@ghost
Copy link

ghost commented Aug 5, 2023

The package supports WSS clients and servers.

To dial a connection using WSS, specify "wss" as the URL scheme. Search for "wss" in client.go to find the relevant code.

To handle WSS connections on the server, register your websocket endpoint with an HTTP server listening for HTTPS connections. There is no code in the repository specific to serving WSS connections because TLS is handled by the HTTP server.

@flower7434
Copy link

Changes to echo example for using TLS.

Set TLS port (and use all interfaces if wanted).

var addr = flag.String("addr", ":443", "https service address")

Use wss.

homeTemplate.Execute(w, "wss://"+r.Host+"/echo")

Serve TLS with certificate and key.

log.Fatal(http.ListenAndServeTLS(*addr, "server.crt", "server.key", nil))

Generate certificates for testing.
openssl genrsa -out server.key 2048
openssl req -new -x509 -sha256 -key server.key -out server.crt -days 365

Cloudflare example for production.
Add a proxied DNS record for the domain. Create the certificate and key for it under SSL/TLS -> Origin Server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants