hello world, nginx + docker edition (part 1)
Sat down at the keyboard today with a desire to get back to basics.
“In accordance with the ancient traditions of our people, we must first build an app that does nothing except say Hello world.” -Facebook’s React Native tutorial
So today I’m going to do a quick run thru of building a web server that returns ‘hello world’ as html and json, using Nginx and Docker under the covers.
please install Docker before proceeding
-
Let’s run some commands to get our project structure set up:
Here’s the basic structure of the project after the preceeding commands:
Now lets toss some basic HTML in the index.html
file:
Cool. Now we need to set up our nginx.conf
file. These suckers can be massively complicated but we are going to do the bare minimum.
What we are doing here is setting up an HTTP server with 2 “locations” or endpoints:
/api/
returns a JSON payload with a 200 status/
the root which serves up oursrc
directory, which by default serves theindex.html
file. Therefore we don’t need to specify theindex.html
file here.- the events block is required by Nginx but I won’t cover that here. Read more if you desire.
Continued in part two!.html)