DEV Community

Jen Chan
Jen Chan

Posted on • Edited on

Hastily Deploying a Node App on NearlyFreeSpeech.net (Mac OS)

This was so intimidating that I'm just recording what I did so I can remember. Thanks to Conan Lai @letmelol for onsite assistance and this Mopsled blog from 2015, which you should really read instead of my post which only details the terminal commands I used.

Getting started

(For more info See "NFSN Configuration" in Mopsled's post)

  1. Make a NearlyFreeSpeech account.
  2. Create a password
  3. Create a RSA key if you don't have one, run ssh-keygen, which generates a public and private key. You'll need the public one
  4. Go to Profile > Add SSH
  5. To copy your public key, run pbcopy < ~/.ssh/id_rsa.pub in the terminal
  6. Paste your key into the input box, and click Add SSH Key

Preparing my app

My app is a Vue-cli with express server: At this point I had the front end in a different folder than the backend. Two different projects with two package.jsons!

  1. In my front-end project, compile the build into a /dist or /build folder with npm run build
  2. Copy and paste the folder into my server side project folder (express app)
  3. In my app.js, add app.use(express.static ('dist/')) to point the backend at my public directory

Optional: In package.json, I could add a script to run the app run.sh

Deploying

(Also refer to Project Setup)

  1. ssh to my server to get in
    ssh username_websiteNickName>@ssh.phx.nearlyfreespeech.net

  2. To "upload" all your files to the server, copy everything into home/protected/ by running:

    rsync -av ./ username_websitenickname@ssh.phx.nearlyfreespeech.net:/home/protected

    ./ indicates "everything in this folder" as the local path, and username_websitenickname@ssh.phx.nearlyfreespeech.net:/home/protected is the remote path.

Alternately, I could use scp -r ./ username_websiteNickname@ssh.phx. nearlyfreespeech.net:/home/protected

Remember to keep a space between local and destination paths.

Apparently rsync is really cool because it only updates what's changed/new in your files.

Make It Live

  1. See ["Configure NearlyFreeSpeech.net Daemon" and "Configure Proxy"] on Mopsled's post(http://www.mopsled.com/2015/run-nodejs-on-nearlyfreespeechnet/)

HELP: Getting a TLS certificate

Being the tutorial smartass I think I am, I thought I could create my own TLS certificate after reading this gist thread by running tls.sh in /home/protected. I was wrong. Now this task keeps running and I get an email everyday about how it failed. Does anyone know what I can do to enable https properly?

email of my server error message

UPDATE:

In a total duhh moment I found that scheduled tasks are listed in the GUI.
I went to Sites, and on the left hand side I found a sidebar listing "Scheduled Tasks" where the tls.setup task was listed, with a "Remove" button to the right hand side.

Top comments (11)

Collapse
 
defool profile image
Shawn S • Edited

I found the 'article' you suggested to look at on Archive:

web.archive.org/web/20161108020800...

Hello. So after a while using NFS can you give me an estimate of your monthly costs running a Node.js site on their platform. I have an account with them, and have used them as a 'play' site, for fun, everything PHP and static. Just an average hit count and a dollar amount would be great as Node, as I understand it is 'always running'. Right now. It is an offline (non-production) site so it is cheaper:

Here are my costs for last month:January 2020 Expenses
Category January
DNS Charge $0.20
Deposit Fee $1.19
Site Charge $0.31
Storage Charge $2.27
Total $3.97

Collapse
 
nickgottschlich profile image
Nick Gottschlich

Thanks for finding this archive, saved my butt! Got my website online thanks to this 😁

Collapse
 
jenc profile image
Jen Chan

I live for these moments knowing many a tutorial saved me like this 😄

Collapse
 
jenc profile image
Jen Chan

Thank you! I didn't realize the link was broken and just replaced it!

Collapse
 
howardah profile image
howardah

Hey Jen, just curious to know if you ever got the TLS certificate working? I'm trying to do this with my node app on nearlyfreespeech.

Thanks!

Collapse
 
ianmcorvidae profile image
Ian McEwen

Hi; I actually ended up figuring out how to do this for my own thing. NFSN's provided tls-setup script expects the /home/public/.well-known directory to be served up at /.well-known on your site, and that's the main thing (as far as I can tell) that makes it not work well for custom daemons. For my thing, I happened not to need all of / to be proxied to node, so I set up more focused proxies to the specific subpaths I needed, and used the "Apache 2.4 Generic" site setting so that their included servers would serve up the well-known directory. I suspect that it'd be possible to get this to work with anything so long as that directory serves up files as expected so that the ACME challenges can go through.

Collapse
 
jenc profile image
Jen Chan

Thanks so much for this note Ian! Seriously... it's called the ./well-known directory? Lmao.

I'll update the post with a note for others who are looking. Thanks again!

Collapse
 
jenc profile image
Jen Chan

Hi there, oh gosh, I can't remember... I have to go and check!

Collapse
 
jenc profile image
Jen Chan

Unfortunately I didn't. Let me know if you find out!

Collapse
 
klausdonnert profile image
Klaus Donnert

The procedure in the 2015 Blog post still works.

Collapse
 
jenc profile image
Jen Chan

Great to know!