Tuesday, November 24, 2020

NGINX with DOCKER

NGINX with DOCKER

Summary

  • Serving Static Content (HTML, CSS, JavaScript)
  • Reverse Proxy (load balancing ): forward requests from clients to backend servers which handle the requests.
  • API Gateway(distributing traffic): Acts as a single entry point for all API requests and distributing traffic
  • SSL/TLS Termination: it decrypts incoming traffic, inspects it, and then re-encrypts it before sending it to the backend servers.
  • Caching: NGINX can also be used as an HTTP cache, which can improve website performance by caching frequently requested content and serving it directly from memory
  • load balancing All the above can be set in Config: etc/nginx/nginx.conf

Pre-Req:

  • Docker is already installed in the system.
  • Note:By default nginx runs on port 80

Example 1

	-------------------------- nginx.sh ----------------------------
	cd ~/Desktop
	mkdir nginx
	cd nginx
	echo '\<html\>\<body\> hi\</body\>\</html\>' >> test2.html 
	--------------------------------------------------------
	docker run -it --rm -d -p 8080:80 --name web -v $PWD:/usr/share/nginx/html nginx

open browser http://localhost:8080/test2.html docker stop container_id

Example 2

docker run -p 8000:80 --name nginx_test nginx:latest
  • open browser
  • open link localhost:8000 (You should be able to see the html page)
  • ctrl+c (to quit)
  • docker rm nginx_test
view raw nginx.md hosted with ❤ by GitHub

No comments:

Post a Comment