Nginx on Windows in 5 minutes

Nginx on Windows in 5 minutes or less with Docker

Wait whaat? Nginx on Windows, who cares about that?? Actually many people do. Fortunately now is the greatest time to be a software engineer! Here is why.

I bet you heard about Docker in the past. If you didn’t then you probably living under a rock and you need to come out of there soon. Docker is slowly and surely removing boundaries between different OSes giving you reliable and consistent way to run SAME code on different platforms, whether it’s macOS, Linux or Windows.

There is more – at the recent DockerCon 2017 event Microsoft announced and showcased native support for containers running on Windows Server!

What does this tell us? Docker is here it stay, which is pretty exciting if you ask me.

Anyways, I promised to show you 5 minutes setup of Nginx for Windows so lets get back to that. Yes, I lied a little bit since you will need to install Docker on Windows first.

Now that the installation part is finished, lets move forward. Open your favorite Windows shell (cmd.exe) and type the following command:

docker run -d -p 80:80 --name nginx-test nginx`

At this point docker should start downloading Nginx container from Docker hub (if you don’t have it locally already). If everything goes smoothly, we should see something like this:

Unable to find image 'nginx:latest' locally
latest: Pulling from library/nginx

fdd5d7827f33: Pull complete
a3ed95caeb02: Pull complete
716f7a5f3082: Pull complete
7b10f03a0309: Pull complete
Digest: sha256:f6a001272d5d324c4c9f3f183e1b69e9e0ff12debeb7a092730d638c33e0de3e
Status: Downloaded newer image for nginx:latest

Once downloaded and started, open the browser and type “http://localhost” in there. Now hit enter, hold your breath and wait, in a few moments you should see awesome welcome page from Nginx:

nginx on windows welcome page

If you see the welcome page, that means your Nginx on Windows install is working (yay!) and you can start playing with it some more.

Next I would recommend to explore docker volumes. It will help us to mount dir with local Nginx configuration to the docker container. Then there is docker-compose which helps to create projects that can be easily shared between different people. The last option is to build new container from scratch.

As we increasingly rely on clouds and dynamic infrastructures (with autoscale and whatnot), we can’t just use static configurations as we used to. Modern container technologies, while simplifying some parts, often add yet additional twists and questions.. In the future I plan to cover Nginx for changing environments so make sure you sign up to my newsletter! and as usual I’m looking forward to your questions and comments below.

Wake up, Neo... The matrix has you...

I'm Sergey Khaladzinski (@gansbrest). Not so long ago, I decided to take my life to another level. If you'd like to follow my journey, feel free subscribe below to get periodic updates about my life and the new stuff I explore.

Don't be mad if you don't receive anything from me for a period of time. I'm still learning the process.. Powered by ConvertKit

Leave a Reply

Your email address will not be published. Required fields are marked *