Skip to content

bowmans-dev/nginx_web_server_docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction to NGINX Understand and Deploy Layer 4/Layer 7 Load Balancing, WebSockets, HTTPS, HTTP/2, TLS 1.3 with NGINX (With Docker)

  1. NGINX as a Web Server

create a directory/folder for your nginx implementation:

mkdir nginx-container

cd nginx-container


the following example will spin up nginx on the default port commonly used for http (both the specified port and --name ng1 are optional)_

docker run --name ng1 -p 80:80 -d nginx

view in CLI or browser:

  • curl http://localhost:80
  • or search localhost/ in your browser

(you should see the nginx welcome page)


stop the running demo container: docker stop ng1

delete the demo container: docker rm ng1


create a directory/folder for your html file: mkdir html cd html vim index.html /editor of your choice

add your index page e.g:

<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
   <h1> Hello Mars <h1>
</body>
</html>

setup new container:

(important: make sure to replace this next section: /home/desk/Desktop/nginx-container/html: with your own directory path to the new html folder)

 docker run --name ng1 -p 80:80 -v /home/desk/Desktop/nginx-container/html:/usr/share/nginx/html -d nginx

test the new html directory content/page is being served instead of the default nginx welcome page:

curl http://localhost:80

  • or search localhost/ in your browser

(so far.. nginx is being implemented as a simple web server)


The next part of this course: https://www.udemy.com/course/nginx-crash-course/ demonstrates how to override the default configuration of nginx setting it up as a reverse proxy which will point to 3 new instances of your continerised app, nginx will be configured to balance the load between them

About

NGINX with Docker Setup

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published