X button icon

Jasmine Nackash is a multidisciplinary designer and developer intereseted in creating unique and innovative experiences.

Week #07

Node.js setup

I already installed node.js on my server when I set up nginx but I'm not sure how to actually upload files to the server. I used the following command to get access to the html file that is currently set up on my domain:

sudo nano /var/www/jn/html/index.html

I could just write everything via nano but that would be a pain. In class Tom was using some FTP client whose name I didn't get, but I have Fetch installed from a previous class so I thought I'd see if it'll work here too — it did, and by following the same path from the command line I located the html file. I can go that route, just use the Fetch interface to upload everything, but I'm going to give this a try first.

So the files we want to work with are in a /var/www/<username>/html folder (/var is /home's sibling). I'm not sure exactly what's going on there — what's with the var folder? And then there's the www folder (but this should also work for the root domain?), and then inside of that there are three folders — the two domains jn2813itpio (the itp domain I initially set up), jn (my current one), and "html". What is weird to me is that it's "jn2813itpio" — no dots, and it's a folder so it shouldn't be an issue. What I'm assuming is happening is — the html folder is the default nginx html page  (I remember seeing it when I first set up nginx, and then disappearing after setting up my server block). So I guess I chnged it when I configured the server?), but I do wonder if it would serve different pages based on the different folder (the jn domain and the itp domain).

Anyway, all of this was to say that I guess my project directory should go in my domain folder. I'm not sure how to move forward though — neither Fetch nor the command line allow me to add new files or change the existing one. When opening index.html in nano I get [ File 'index.html' is unwritable ]. A quick google later apparently I have to change the owner to my user instead of the root — sudo chown -R $USER:$USER /var/www — but I definitely already did that when I set up the server block... Why again?

I installed express and followed the rest of the instructions and started by just pasting the server.js code from glitch and... it doesn't work — I'm getting a 404. What does work is reading the code and realizing the URL I should be accessing is using HTTP and not HTTPS, and also is on port 8080 (not sure why we have to specify the port though? If it's HTTP isn't it already going through 8080?).

Initially I just copied the code as is from Glitch into my own files and ran my server. But the requests either don't work or I'm not sure how to access it correctly.

I see this page but all the curl commands I try (from the readme file) output either this:

<html>

<head><title>301 Moved Permanently</title></head>

<body>

<center><h1>301 Moved Permanently</h1></center>

<hr><center>nginx/1.24.0 (Ubuntu)</center>

</body>

</html>

Or a 404 Not Found error.

The only one that actually logged the html page was   curl 'http://www.jn.jnackash.com:8080'. And the following appeared as soon as I restarted the server:

While looking for resources on the class site, I realized I'm getting ahead of myself and should probably wait for next class so I can have a better understanding of what needs to happen and why things are the way they currently are.