0

I am very lost at the moment, so much so that I actually signed up because of my problem. So here we go: I am running a System with Plex and I am trying to get a node.js Backend with socket.io to work that is running behind Nginx. The proxy pass for my HTML (I am using ejs to be precise, not sure if relevant) hosted via express works like a charm. But I get a 404 error when my website tries to connect to my backend via socket.io.

My Nginx directives as configured via Plex:

location = / {

    proxy_set_header        Host                    $host;
    proxy_set_header        X-Real-IP               $remote_addr;
    proxy_pass http://127.0.0.1:50090;
}

location /socket.io/ {
    proxy_http_version      1.1;

    proxy_set_header        Upgrade                 $http_upgrade;
    proxy_set_header        Connection              "upgrade";
    proxy_set_header        Host                    $host;
    proxy_set_header        X-Real-IP               $remote_addr;
    proxy_set_header        X-Forwarded-For         $proxy_add_x_forwarded_for;

    proxy_pass http://127.0.0.1:50090/socket.io/;
}

My client connecting to the backend:

var socket = io.connect('https://subdomain.mydomain.com', {secure: true});

My Backend listening:

const app = express();

const http = require('http').createServer(app);
const io = require('socket.io').listen(http);

http.listen(50090, "127.0.0.1");

There is a lot about this on the internet, but it seems like I tried everything by now and nothing worked. Likely because I am very new to this.

Ramana V V K
  • 1,245
  • 15
  • 24
Matthias
  • 1
  • 1
  • I would recommend you to try it on your pc without nginx to make sure it works as expected. On the client use `var socket = io();` it should connect to the same url as you have in the address in your browser. – Molda May 01 '20 at 22:01
  • Without nginx everything works fine. I tried var socket = io(); but it did not make a difference, though I will keep it in mind for the future. Thanks for your Input. – Matthias May 01 '20 at 22:59

0 Answers0