Hey there,
I am trying to get websockets to run on my setup. But right now it just returns a 404.
I am using a simple nodejs websocket server and React for the webfrontend. However, if react tries to communicate with the websocket server, it just returns a 404.
If I define a different port (e.g. 8081) it works. However I have to use port 443 in order to run this on the infrastructure of my client.
This is my docker-compose.yml
version: "3.9" # optional since v1.27.0
services:
reverse-proxy:
# The official v2 Traefik docker image
image: traefik:v2.4
container_name: ${COMPOSE_PROJECT_NAME}_traefik
# Enables the web UI and tells Traefik to listen to docker
command:
- "--api.insecure=true"
- "--providers.docker"
- "--providers.file.directory=/etc/traefik/dynamic_conf/"
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
ports:
# The HTTP port
- "80:80"
- "443:443"
# The Web UI (enabled by --api.insecure=true)
- "8000:8080"
volumes:
# So that Traefik can listen to the Docker events
- /var/run/docker.sock:/var/run/docker.sock
- ../setup/ssl:/tools/certs
- ../setup/traefik/certs-traefik.yml:/etc/traefik/dynamic_conf/conf.yml
networks:
vpcbr:
ipv4_address: 10.5.0.2
labels:
- traefik.http.routers.traefik=true
- traefik.http.routers.api.entrypoints=websecure
- traefik.http.middlewares.sslheader.headers.customrequestheaders.X-Forwarded-Proto=https
- traefik.http.routers.${COMPOSE_PROJECT_NAME}_traefik.tls=true
- traefik.http.routers.${COMPOSE_PROJECT_NAME}_traefik.rule=Host(`traefik.showroom.local`)
react:
image: nginx:1.20.1-alpine
hostname: react
container_name: ${COMPOSE_PROJECT_NAME}_react
volumes:
- ../apps/react/dist:/usr/share/nginx/html
- ../setup/nginx/default.conf:/etc/nginx/conf.d/default.conf
networks:
vpcbr:
ipv4_address: 10.5.0.5
labels:
- traefik.http.routers.${COMPOSE_PROJECT_NAME}_react.tls=true
- traefik.http.routers.${COMPOSE_PROJECT_NAME}_react.entrypoints=websecure
- traefik.http.routers.${COMPOSE_PROJECT_NAME}_react.rule=Host(`www.showroom.local`,`showroom.local`)
websocket:
image: node:12.22.2-alpine
container_name: ${COMPOSE_PROJECT_NAME}_ws
mem_limit: 2G
working_dir: /home/node/app
command: sh /home/node/app/run.sh
#ports:
# - 8081:8081
volumes:
- ../apps/ws:/home/node/app
- ../setup/ssl:/home/node/app/ssl
networks:
vpcbr:
ipv4_address: 10.5.0.6
labels:
- traefik.http.middlewares.sslheader.headers.customrequestheaders.X-Forwarded-Proto=https
- traefik.http.routers.${COMPOSE_PROJECT_NAME}_ws.tls=true
- traefik.http.routers.${COMPOSE_PROJECT_NAME}_ws.rule=Host(`ws.showroom.local`)
networks:
vpcbr:
driver: bridge
ipam:
config:
- subnet: 10.5.0.0/16
gateway: 10.5.0.1
Any idea what's wrong?