/    Sign up×
Community /Pin to ProfileBookmark

Websockets question

I did a websocket server using Go [here](https://github.com/gorilla/websocket/blob/master/examples/echo/server.go) This code works out of the box on my local computer.

But I do not think that this is a Go question, because this code works on my local computer.

[url=https://postimages.org/][img]https://i.postimg.cc/7ZYLrNBv/ws.png[/img][/url]

But when moving to a VPS with Nginx proxy this fails. As this seems to “converts” from https:// to wss:// or ws:// I have no clue what I have done wrong. https://ws.go4webdev.org (live)

The console gives this error:

>

WebSocket connection to ‘wss://localhost:8080/echo’ failed:

Any clue how I can make this work?

to post a comment
Full-stack DeveloperJavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@sibertauthorSep 30.2022 — I think I found a solution. It seems that Websockets is an old protocol that is only supported by HTTP 1.1 (cannot confirm this). But when added this to the Nginx sites-available, [it seems to work](https://ws.go4webdev.org).

``<i>
</i> location / {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}<i>
</i>
``



If anybody can confirm this, I should be nice to know.
×

Success!

Help @sibert spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...