I have a Laravel app served through Traefik and an Nginx proxy.
This is my docker-compose file with the laravel service. My idea was to setup a subdomain on ws.v3.localhost
for the Reverb requests and to have Traefik add the /ws
prefix for Nginx to know how to handle these requests
laravel:
(...)
labels:
- "traefik.enable=true"
- "traefik.http.routers.laravel.entrypoints=web"
- "traefik.http.routers.laravel.rule=Host(`ttfr.v3.localhost`)"
- "traefik.http.middlewares.ws-prefix.addprefix.prefix=/ws"
- "traefik.http.routers.laravel-ws.rule=Host(`ws.v3.localhost`)"
- "traefik.http.routers.laravel-ws.middlewares=ws-prefix"
- "traefik.http.services.laravel-ws.loadbalancer.server.port=80"
Then I have this nginx config file,
server {
listen 80;
index index.php index.html;
charset utf-8;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/app/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
add_header 'Content-Security-Policy' 'upgrade-insecure-requests';
add_header 'Access-Control-Expose-Headers' 'X-Inertia';
location /ws/ {
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";
access_log /var/log/nginx/ws_access.log;
error_log /var/log/nginx/ws_error.log;
proxy_pass http://localhost:8088;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
gzip_static on;
proxy_set_header X-Forwarded-Proto https;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ .php$ {
fastcgi_pass localhost:9000;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /.(?!well-known).* {
deny all;
}
}
The reverb server is running on 0.0.0.0:8088
If I bind the ports from the container in my docker-compose config (8088:8088), the app is able to send the Reverb requests directly to localhost:8088 and it works. But when I use the config above and I set up these values in my .env
, it does not work anymore.
REVERB_HOST=ws.v3.localhost
REVERB_PORT=80
REVERB_SCHEME=http
REVERB_SERVER_HOST=0.0.0.0
REVERB_SERVER_PORT=8088
Does my approach make sense? Is there something I’m missing? I’d appreciate any tips on how to debug this and identify where the problem comes from.