I have a server running Ubuntu 20.04, set up with an SSH Key, and I have installed Nano using Docker -
docker run --restart=unless-stopped -d -p 7075:7075/udp -p 7075:7075 -p 127.0.0.1:7076:7076 -p 127.0.0.1:7078:7078 -v /root/nano/:/root --name nano nanocurrency/nano:latest
On the VPS GUI ports 22, 443, and 7075 are open for inbound traffic.
I have a working WebSocket running on localhost:7078 which returns a stream of data to the terminal.
Nginx version 1.18.0 is installed and when I run systemctl status nginx it claims to be active with no errors, but when I try to connect from my laptop nothing happens.
Here's my Nginx config -
server {
listen 443;
# host name to respond to
server_name 000.000.00.000;
location / {
# switch off logging
access_log off;
# redirect all HTTP traffic to localhost:7080
proxy_pass http://localhost:7080;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# WebSocket support (nginx 1.4)
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
And node.js Websocket -
const WS = require('ws');
const ReconnectingWebSocket = require('reconnecting-websocket');
// Create a reconnecting WebSocket.
// In this example, we wait a maximum of 2 seconds before retrying.
const ws = new ReconnectingWebSocket('ws://localhost:7078', [], {
WebSocket: WS,
connectionTimeout: 1000,
maxRetries: 100000,
maxReconnectionDelay: 2000
});
// As soon as we connect, subscribe to block confirmations
ws.onopen = () => {
const subscription = {
"action": "subscribe",
"topic": "confirmation"
}
ws.send(JSON.stringify(subscription));
};
// The node sent us a confirmation
ws.onmessage = msg => {
console.log(msg.data);
if (msg.data.topic === "confirmation") {
console.log ('Confirmed', data.message.hash)
}
};