-
Notifications
You must be signed in to change notification settings - Fork 658
"Error in connection establishment" when nginx points to another server #291
Description
Hello!
I'm stuck in situation how to pass websockets requests in situation when I've 2 servers in chain.
Here is it
- A domain name (domain.dev), with A record
- intranet server Add Debug Dashboard #1, which has external IP and nginx with SSL installed that proxifying requests from external IP to internal, depending on domain name
- intranet server Websockets route #2, which contains service with websocket on standart port, this server has no direct access to internet
So sheme is
Domain.dev (A record points to Server #1 ) => Server #1 (with nginx and SSL for domain.dev) => Server #2 (with websocket server on standart port 6001)
I tried lots of variants and always get errors like
WebSocket connection to 'wss://******' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
WebSocket connection to 'wss://********' failed: WebSocket is closed before the connection is established.
As I mentioned problem is that my service is configured for accepting http connections, but connections is sending via https (wss:).
I read official manual https://docs.beyondco.de/laravel-websockets/1.0/basic-usage/ssl.html#usage-with-a-reverse-proxy-like-nginx but can't understand how handle same 'location' for http and websockets requests
So this config part from example
location / {
proxy_pass http://127.0.0.1:6001;
is for websockets only? But how I can forward normal requests?
My Configs
app.js
window.Echo = new Echo({
broadcaster: 'pusher',
key: process.env.MIX_PUSHER_APP_KEY,
cluster: process.env.MIX_PUSHER_APP_CLUSTER,
wsHost: window.location.hostname,
disableStats: true,
wsPort: 6001,
wssPort: 6001 //HTTPS only
});
broadcasting.php
'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
'host' => '127.0.0.1',
'port' => 6001,
'encrypted' => false, //# for HTTP
'scheme' => 'http', //# for HTTP
//'scheme' => 'https', //#for HTTPS
'curl_options' => [
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0,
]
],
websockets.php
[
'id' => env('PUSHER_APP_ID'),
'name' => env('APP_NAME'),
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'path' => env('PUSHER_APP_PATH'),
'capacity' => null,
'enable_client_messages' => true,
'enable_statistics' => false,
],
nginx config is total trash now :) so please point me to right direction.