Hallo,
like the title says, i want to host an instance of the networking server(GitHub - needle-engine/networking-local: Run the Needle Engine Networking server locally or host your own) behind nginx inside a docker container.
I manage to get it to work without nginx, but not behind the reverse-proxy.
Every article on the internet says more or the less the same how to proxy a websocket connection, so my conclusion is, that there are some details on the Needle Engine side that make problems.
My nginx config is as follows:
server {
listen 80;
listen [::]:80;
location /game/server {
proxy_pass http://websocket/socket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}
}
upstream websocket {
# game-net is the service name of the container holding the server
server game-net:9001;
}
My dockerfile containing the server is as follows:
# create node container
FROM alpine:3.17 as build
# install git
RUN apk add git
# set working dir
WORKDIR /repo
# install repo
RUN git clone https://github.com/needle-engine/networking-local.git
# create final image
FROM node:18.16.0-alpine3.17
WORKDIR /app
# copy only what is needed
COPY --from=build /repo/networking-local/express ./
# install dependencies
RUN npm install
# set port
ENV port=9001
# expose port
EXPOSE 9001
# run websocket server
CMD [ "npm", "start"]
And in Unity on the networking component my settings are:
Localhost: http://localhost/game/server
I am not an expert at websockets, so i don’t really know where the problem could be. As i said before, without nginx and
Localhost: ws://localhost:9001/socket
it works. I hope i am at the right place to ask this here.
Many thanks in advance.
Wutterlfy
by user 1122855088558456862