I have no doubt the comments here does not work. By the looks of things, it should. No matter what I've done, I'm getting 502
. My setup is a bit different:
We have an ec2 with AWS. We have a private IP (10.0.0.1) and a public IP (52.0.0.1). After installing Laravel Websockets, I can start up a websocket server (ws) with php artisan websockets:serve
as a Pusher Replacement.
Here's where I'm confused, should I start the ws with --host=10.0.0.1
? Here's my nginx setup:
# 52.0.0.1 is not needed here. I put it here to troubleshoot ws connection
# <actual-domain-name> is the domain name ie: foobar.com
server_name 52.0.0.1 <actual-domain-name>;
# The usual Laravel configs
[..]
location /v2/api {
# We use the public ip address here.
# I see no mention of the private IP in this config
# Hey, everything works
proxy_pass http://52.0.0.1/api/;
}
# I need to implement web sockets
location /v2/api/ws {
# This is where I'm lost. Should I use 127.0.0.1, 10.0.0.1 or 52.0.0.1?
proxy_pass http://127.0.0.1:6001;
# Allow the use of websockets
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
With the command to start up ws server php artisan websockets:serve
then using the websocket section of Postman, I make the request: ws://<actual-domain-name>/v2/api/ws
I get 502 Bad Gateway.
No matter how I start ws:
# I start it manually for troublshooting
php artisan websockets:serve --host=10.0.0.1
php artisan websockets:serve --host=127.0.0.1
php artisan websockets:serve
# It wont let me start with
# php artisan websockets:serve --host=52.0.0.1
I cannot make a connection. I have not mentioned ssl just to keep things simple so I make the request with ws://
instead of wss://
. I was advised that port 6001
was enabled in AWS and I have also enabled port 6001
for ufw
.
Would the laravel-websockets config interfere with using php artisan websockets:serve
?
Edit:
config/broadcasting.php
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
'useTLS' => true,
'encrypted' => true,
'host' => 127.0.0.1,
'port' => 6001,
'scheme' => 'http', // I'll use https once I get this working
'curl_options' => [
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0,
],
],
],