Comments (9)
This is brilliant!
I use nginx and so I wanted to do the same for it. Lots of benefits to this, like no worries about having another port open in your firewall etc!
After some testing this is what you need to do to make this work with nginx.
Open your nginx conf file for the website you want to use the websockets on, it's normally found in /etc/nginx/sites-available/<yoursite.com>
server {
listen 80;
listen 443 ssl default_server;
server_name example.com;
root "/home/vagrant/example.com/public";
index index.html index.htm index.php;
charset utf-8;
### Add this section for websockets reverse proxy
### Assumes you want to run your laravel-echo-server on localhost with a port of 6001
location /socket.io {
proxy_pass http://127.0.0.1:6001;
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;
}
###END OF WEBSOCKETS SECTION
location / {
try_files $uri $uri/ /index.php?$query_string;
}
<snip>
Don't forget to restart nginx sudo service nginx restart
.
Now you can set your laravel-echo-server.json
to have the following:
<snip>
"devMode": false,
"host": "127.0.0.1",
"port": "6001",
"protocol": "http",
"referrers": [],
And finally in your JS bootstrap.js
file (or where ever you define Echo):
import Echo from "laravel-echo"
window.echo = new Echo({
broadcaster: 'socket.io',
host: { path: '/socket.io' }
});
That's the setup complete.
Just start the echo server (use the instructions) and then ensure that the page you load on your website has the JS loading ok. Your system is setup to receive broadcasts!
Thanks @alexmontoanelli - that's really cool!
from laravel-echo-server.
Does this use apaches ssl certificates, or do you still need to setup those in the config?
from laravel-echo-server.
You can set ssl on apache side in the usual way...will works ( I use here)
from laravel-echo-server.
Don't you have problems with the number of apache processes/threads that remain active/open because of the sockets?
from laravel-echo-server.
I am not able to setup on amazon ec2 using apache
from laravel-echo-server.
I get an errror
{
"code": 0,
"message": "Transport unknown"
}
from laravel-echo-server.
@solancer did you find a solutions? facing the same issue here
from laravel-echo-server.
With config :
<location /socket>
RewriteEngine On
RewriteCond %{QUERY_STRING} transport=websocket [NC]
RewriteRule /(.*) ws://localhost:3001/socket.io/%{QUERY_STRING} [P,L]
ProxyPass http://localhost:3001
ProxyPassReverse http://localhost:3001
i am getting error:
Error during WebSocket handshake: Unexpected response code: 400
from laravel-echo-server.
When i am using debug mode i see that thing:
engine bad request: unexpected transport without upgrade
from laravel-echo-server.
Related Issues (20)
- Is the package compromised? HOT 6
- Laravel-echo-server events listeners custom callbacks
- Redis6 ACL Support HOT 1
- 运行一会,就会中断,提示截图显示的错误 HOT 2
- Cannot find module '../dist/cli' - supervisord
- Redis 6 ACL config HOT 1
- Connection refused on docker
- Laravel Echo Server work and client side error only at server HOT 2
- Is there ways to emit data from client (socket.io-client) to laravel-echo-server? HOT 2
- Laravel Echo PresenceChannel vs listen events doesn't work HOT 2
- 使用Laravel 5.8 广播系统,本地研发没有事情,上线后握手阶段,第一次OK,第二次报502,第三次报session id unknown,现在不知道是那个地方出问题了?求帮助 HOT 1
- Is `tlaverdure/laravel-echo-server` abandoned? HOT 6
- Is the cors configuration even working? HOT 1
- echo server socket.io.js error
- support redis cluster
- Redis TTL key is store forever
- CSRF token mismatch after session timeout
- npx laravel-echo-server start HOT 1
- Unable to join channel. Member data for presence channel missing HOT 1
- Is this project compatible with Socket.io v4? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-echo-server.