chill117 / lnurl-node

Flexible lnurl server implementation with API and CLI implemented in nodejs.
MIT License
97 stars 26 forks source link

Host & Port for production server. #35

Closed chungquantin closed 3 years ago

chungquantin commented 3 years ago

Hi @chill117, when I tried to host my server on production, the host and port (removed or not) will be localhost. Therefore, my lnurl server does not run on production (local development works fine).

// The host for the web server:
host: 'localhost',
// The port for the web server:
port: 3000,
// The protocol to use for the web server:
protocol: 'http',
chill117 commented 3 years ago

How are you running the server? CLI or API? And how are you providing the configuration options?

chungquantin commented 3 years ago

I use API to create the server. Here is my configuration file

{
    "host":"localhost",
    "port":8080,
    "protocol":"http",
    "url": "My heroku server url",
    "endpoint": "/lnurl-server",
    "lightning": {
        "backend": "lnd",
        "config": {
            "hostname": "XXX",
            "cert": "XXX",
            "macaroon": "XXX"
        }
    },
    "store":{
        "backend": "knex",
        "config": {
            "client": "mysql",
            "connection": {
                "host": "XXX",
                "user": "XXX",
                "password": "XXX",
                "database": "XXX",
                "port": 3306
            }
        }
    }
}
chungquantin commented 3 years ago

When checking the heroku logs on production shell, it throws this 2021-07-07T12:37:45.355460+00:00 app[web.1]: Lnurl server listening at http://localhost:8080 So I wonder lnurl server is hosted or not

chill117 commented 3 years ago

Looks like it's working as expected. Are you trying to reach the lnurl-server from the public internet? It's recommended to run it behind an nginx (or other) reverse-proxy to handle TLS-termination at the host machine.

Try setting "host" equal to 0.0.0.0 and see if it works as you expect.

chungquantin commented 3 years ago

@chill117 It seems doesn't work. Can I see your config for the production server?

chill117 commented 3 years ago

I use a combination of docker and nginx to run lnurl servers in production. So I don't think it would help much for your situation. But you can have a look at the bleskomat-server project - it has example docker-compose files:

https://github.com/samotari/bleskomat-server

I suspect this is a networking issue in your Heroku setup.

What happens when you open a browser and type the host machine's IP address? Are you able to reach it?

prusnak commented 3 years ago

This is what I have in my config:

  "protocol": "http",
  "host": "0.0.0.0",
  "port": "3000",
  "url": "http://example.com:3000",
   "endpoint": "/lnurl",

Afterwards the http://mydomain:3000/lnurl should work.


Of course if you want HTTPS, you need to use nginx with letsencrypt:

Here's the config

server {
    root /var/www/example.com/html;
    index index.html;

    server_name example.com;

    location / {
        proxy_pass http://127.0.0.1:3000;
    }

    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
chungquantin commented 3 years ago

@chill117 Thank you, I will take a look! @prusnak Which hosting service do you use? Seems like Heroku does not allow sub domain