Anyone have any idea at all? A direction we can go down. Anything, as we have been stuck on this one for over a week now.
Laravel-Websockets, Nginx, Docker, Apache Mesos & more in this stack - 404 error
When we setup laravel-websockets locally in docker, everything worked wonderfully; however, when it all got pushed to prod, problems arose. Consequently, we have to split up our main site into one server and the websocket server into a different server. All of these sites are on a corporate internal network and do not use SSL.
So, the main application is Laravel 6 running on Centos, Apache 2.4, and PHP 7.3. It can connect to the websocket server but anytime laravel broadcasts an event we get a 404 error for this endpoint:
apps/XXXXXX/events?auth_key=XXXXXXX&auth_signature=XXXXXXX&auth_timestamp=XXXX&auth_version=1.0&body_md5=XXXXX
The websocket server is Centos, PHP 7.3, Nginx 1.8 setup as a reverse proxy using spaties / beyondcodes example conf file.
map $http_upgrade $type {
default "web";
websocket "ws";
}
server {
listen 80;
server_name XXXXXXXXX;
root /opt/rh/rh-nginx18/root/usr/share/nginx/www/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
charset utf-8;
location / {
try_files /nonexistent @$type;
}
location @web {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 500 502 503 504 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location @ws {
proxy_pass http://127.0.0.1:6001;
proxy_set_header Host $host;
proxy_read_timeout 60;
proxy_connect_timeout 60;
proxy_redirect off;
# 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;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
My whole team is new to nginx so we figure there is probably an issue there or something else that we have setup incorrectly. We know our events and broadcasting within the main laravel app is correct, because it worked when it was all running on a single Apache cluster. Our issue was, that corporate would not open a port in the firewall other than 80 and 443. We are opting to split traffic across 80 with nginx as per beyondcode's documentation.
Any thoughts on this? We are at a loss. Thank you all!
Edit:
I should add we are using Laravel Echo with Pusher.JS for the front end:
import Echo from 'laravel-echo';
window.Pusher = require('pusher-js');
window.Echo = new Echo({
broadcaster: 'pusher',
key: process.env.MIX_PUSHER_APP_KEY,
wsHost: 'XXXXXXXXXX',
wsPort: 80,
disableStats: true
});
Please or to participate in this conversation.