I have been trying to deploy my chat app on my home Ubuntu server. It works locally when i connect to it using the internal ip or local server hostname.
I am using an nginx reverse proxy to change over from http://localhost:3000 to my external domain so that I can access it via the internet externally: http://tfmserver.dynu.net/
Nginx proxy:
server {
listen 80;
listen [::]:80;
root /var/www/tfmserver.dynu.net/html;
index index.html index.htm index.nginx-debian.html;
server_name tfmserver.dynu.net;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
I seem to get errors similar to the following but it is sometimes different depending on what I attempt to do to fix it:
WebSocket connection to 'ws://tfmserver.dynu.net/socket.io/?EIO=3&transport=websocket&sid=wQY_D0JOZm4VWGXgAAAA' failed: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT
or
POST http://tfmserver.dynu.net/socket.io/?EIO=3&transport=polling&t=MklujE_&sid=fbdZir8lxOlMOZm6AAAA net::ERR_CONNECTION_TIMED_OUT
According to some posts people have made about this error they are saying that Chrome is trying it as SSL but it is not being served that way, however I have added SSL to the server and into the project but it does not resolve the issue. At the moment I have it removed, but would not mind adding it back in if possible once it is working.
I've tried everything I can from all the possible other questions posted here, none are resolving the issue.
How can I get this to work externally? What am I doing wrong?
Here are the relevant parts of the project for the sockets. If you need anything else that could help, please let me know - Thanks in advance!
server:
var express = require('express');
var app = express();
var server = require('http').createServer(app);
var io = require('socket.io').listen(server);
server.listen(process.env.PORT || 3000, 'localhost');
client:
var socket = io.connect();
UPDATE: - Note: I just connected to it from my work computer and it works?! But it does not work in my own network when trying to use the external address? What's up with that?