-
Notifications
You must be signed in to change notification settings - Fork 104
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
Laravel Reverb in Production Server #107
Comments
What happens if you try https://websockets.amypo.com:8080 in the browser? |
When I visit this URL it gives me "Not Found" error in a blank page 404 |
do you use cyberpanel ? |
No |
It works fine for me on local but I get this error on the server. The server is with DO and Laravel Forge with the switch turned on. I'm using the same settings as amypo-tech OP for Reverb |
Setting Up Subdomain for Reverb ServerTo integrate Reverb with your Laravel application, follow these steps: Create a Subdomain: Begin by creating a subdomain for your Reverb server. This can typically be done through your domain registrar or hosting provider's control panel. Let's say your subdomain is reverb.example.com. Configure Proxy Settings: Set up your web server to proxy requests from your subdomain to the Reverb server's IP and port. Assuming the Reverb server's default IP is 0.0.0.0 and port is 8080, configure the proxy settings to forward requests from reverb.example.com to 0.0.0.0:8080. Configure Laravel Echo: Update your Laravel Echo configuration to use the newly created subdomain reverb.example.com and the default HTTP port 80. This ensures that Laravel Echo can communicate with your Reverb server through the designated subdomain. VITE_REVERB_HOST='reverb.example.com'
VITE_REVERB_PORT=80
VITE_REVERB_SCHEME=http Adjust Reverb Configuration: In your Laravel application's configuration file (typically .env), specify the Reverb host and port. Update the REVERB_HOST to "localhost" and REVERB_PORT to 8080. Your .env file should look like this: Copy code
REVERB_HOST="localhost"
REVERB_PORT=8080 Test Connection: After making these configurations, test the connection by sending an event to Reverb. If everything is set up correctly, your Laravel application should be able to communicate with the Reverb server via the configured subdomain and port. By following these steps, you should have successfully integrated Reverb with your Laravel application using a subdomain-based approach. |
it works great. |
We were able to configure ours to use the same domain name as our app by using the following setup: # NGINX config
...
location /ws/ {
proxy_pass http://127.0.0.1:6050/;
proxy_http_version 1.1;
proxy_set_header Host $http_host;
proxy_set_header Scheme $scheme;
proxy_set_header SERVER_PORT $server_port;
proxy_set_header REMOTE_ADDR $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
} # .env
...
REVERB_SERVER_HOST=127.0.0.1
REVERB_SERVER_PORT=6050
REVERB_APP_ID=1234
REVERB_APP_KEY=key
REVERB_APP_SECRET=secret
REVERB_HOST=127.0.0.1
REVERB_PORT=6050
REVERB_SCHEME=http
VITE_REVERB_APP_KEY="${REVERB_APP_KEY}"
VITE_REVERB_HOST="example.com"
VITE_REVERB_PORT="443"
VITE_REVERB_SCHEME="https"
VITE_REVERB_PATH="/ws"
|
@adrum, I'm pretty sure that configuration will result in a 404 when attempting to broadcast a message from the server as the server routes must all be prefixed with @amypo-tech, can you share your Nginx (or equivalent) configuration? |
<VirtualHost *:80>
|
I have the same type of issue. nothing was helpful. implementing web-sockets in production is like finding water in mars. All the possible ways i have tried.
if some one gives a proper setup or guide from start to end would help for production. in local it took only few minutes to implement. this is the same thing happened before launch of reverb. waiting nearly 6 months to implement in production |
@amypo-tech It's the same issue. You are only serving the reverb/src/Servers/Reverb/Factory.php Lines 97 to 111 in 9e2bd2a
We recommed setting up your server to serve all paths. |
@joedixon that setup I provided is actively working for us. The slash at the end of the proxy_pass directive apparently chops off the /ws from the path before sending it upstream. The server is bypassing NGINX when broadcasting, so it sends it with the correct path. I more or less just wanted to provide another working example. |
Can I view the changes you made to the |
Hello, yesterday I was also struggling a bit to make Reverb work with Forge, but in the end, I figured out a way to make it work. For me, the issue was that I did not have an SSL certificate for the subdomain (Public Hostname) that you set when toggling on Reverb in Forge. I wrote an article about it so maybe it can help someone. You can jump to the end of the article for TLDR so you don't have to read the entire thing. Probably not the best solution, but for now it solved the issue for me. https://tonymasek.com/blog/how-to-make-laravel-reverb-work-on-laravel-forge |
Thanks for your time and for sharing your results. Great. I will give it a try the next time I have to deploy a Reverb server to Laravel Forge. |
No problem, hopefully, it will help you as well 😊 |
This isssue is closed, but I share my solution here https://github.com/laravel/framework/discussions/50675 |
if anyone struggling to make it work on apache cpanel follow this make sub domain with SSL installed on that domain env should be like this
for SSL files and in reverb config file add this
happy coding |
i have same problem and i'm using CyberPanel |
thanks for this man, but why in the world is this not in the docs, ive been struggling to fix the issue for a week. |
@jhalarde thanks for the feedback. The docs do suggest to use |
Can you share your Proxy Configuration? It is not working on my side
|
In case anyone is having issues getting it to work with Caddy
|
@aftabkhaliq86 can you please explain your solution a bit more, I am on Cpanel, and apache, and struggling to implement it on production. |
Hi, it took about 2 weeks but I finally got reverb working on a pre-production staging environment and wanted to share my tips
My config if it helps: reverb.php
broadcasting.php
|
I have use cyberpanle so can give me step for setup reverb |
Here is my solution for Secure Application (SSL)System info:apache2 First update the
|
@jihad28 thank you so much for your efforts.. it makes easier for me.. BTW i set it up on azure.. and created a rabbitmq container for queue .. and now thinking of creating a seprate container for reverb.. although I am not sure if we can do that.. but will try that.. |
@joedixon I have different issue(can say weird issue). I have same configuration like you. Only difference is that I using Nginx server. In my case, I deployed code to test server. when check on my personal machine reverb work.(auth api fired and ping-pong happend). When check on other systems reverb not works. Auth api(/broadcasting/auth) not fired and socket connection shows finished. Vuejs .env
vuejs config.js
Note: REVERB_HOST value is same as domain name. Reverb.php return [
]; laravel .env
vuejs echo connection code
Apache configuration.
Update: |
I found the solution. .env file code will be like this
In vuejs
And in last add proxy setting for web-socket
|
So in case anyone have this issue with Podman (or Docker):
REVERB_APP_ID=app-id
REVERB_APP_KEY=app-key
REVERB_APP_SECRET=app-secret
REVERB_HOST=localhost
REVERB_PORT=8080 # Make sure this value is also used for REVERB_SERVER_PORT
REVERB_SCHEME=http
VITE_APP_NAME="${APP_NAME}"
VITE_APP_URL="${APP_URL}"
VITE_REVERB_APP_KEY="${REVERB_APP_KEY}"
VITE_REVERB_HOST="ws.example.com"
VITE_REVERB_PORT=443
VITE_REVERB_SCHEME=https
ws.example.com {
tls internal
reverse_proxy systemd-laravel:8080
}
import Echo from "laravel-echo";
import Pusher from "pusher-js";
window.Pusher = Pusher;
window.Echo = new Echo({
broadcaster: "reverb",
key: import.meta.env.VITE_REVERB_APP_KEY,
wsHost: import.meta.env.VITE_REVERB_HOST,
wsPort: import.meta.env.VITE_REVERB_PORT ?? 80,
wssPort: import.meta.env.VITE_REVERB_PORT ?? 443,
forceTLS: (import.meta.env.VITE_REVERB_SCHEME ?? "https") === "https",
enabledTransports: ["ws", "wss"],
}); Mixing http/https is not supported. You cannot force |
Reverb Version
1.0
Laravel Version
11
PHP Version
8.2
Description
I have created a sample laravel 11 project and in which I have configured all the requirements for the laravel reverb.
In local machine/setup reverb is working fine. when I deployed in production server for testing I am getting the bellow error.
Steps To Reproduce
None of the above helped me. Kindly help me on this.
.env
config/reverb.php
The text was updated successfully, but these errors were encountered: