I have an Angular web application proxied by nginx. There is a websocet functionality in the application and the relevant section looks as follows:
location /ws {
proxy_http_version 1.1;
proxy_set_header Connection "Upgrade";
proxy_set_header Upgrade $http_upgrade;
proxy_pass http://websocket.server:9090/ws;
proxy_set_header Host $host;
}
nginx is dockerized and is run on my machine by docker-compose
in a custom built image:
FROM node:alpine as node-build
WORKDIR /app
ADD ...
RUN npm install
RUN npm run build --prod
FROM nginx:alpine
ADD nginx.conf ./
COPY --from=node-build /app/... /usr/share/nginx/html
version: "3"
services:
frontend:
build:
context: .
ports:
- 4200:80
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf
There is nothing else in nginx.conf except few other locations:
server {
listen 80;
server_name frontend;
location / {...}
location /ws {...}
location /api {...}
}
I use Docker Desktop for Mac, v.3.2.1.
It works fine except that any connection to /ws
gets closed in exactly 60 seconds, which looks like a timeout set somewhere. What should I check in order to fix it?
UPDATE: for what it worth, the issue does not happen if I access the application through http://localhost:4200, but does happen if I access by the host name or domain name.