current position:Home>Introduction to nginx (learning notes)

Introduction to nginx (learning notes)

2022-04-29 07:03:32Sparkle_ wsl

Nginx

install Windows edition

Official website address
Download and unzip to the local directory ( Don't bring Chinese )

start-up

double-click nginx.exe Ready or use cmd nginx.exe that will do  Insert picture description here

Reverse agent configuration

server {
		#  Listening port 
		listen         88;
		#  Listening address 
		server_name    localhost;
		
		location /{
		#  Proxy to the server address 
		proxy_pass http://127.0.0.1:8081;
		}
		
		#  You can also use the path proxy 
		location /aop{
			proxy_pass http://127.0.0.1:8082;
		}
	}

Case study

One service starts two , The ports are 8081 and 8082,81 visit http://localhost:88/cacheConfig/id 82 visit http://localhost:88/aop/test

  • When we visit http://localhost:88/cacheConfig/id When , The console can see  Insert picture description here
  • When we visit http://localhost:88/aop/test The console prints
     Insert picture description here

Load balancing configuration

upstream wsl{
		#  Server resources  weight  The weight , The higher the value, the higher the access rate 
		server 127.0.0.1:8081 weight=1;
		server 127.0.0.1:8082 weight=2;
	}
	

Case study

  • A total of visits 3 Time http://localhost:88/cacheConfig/id Address , Console printing effect ,82 Will be interviewed 2 Time ,81 Be visited once
     Insert picture description here

copyright notice
author[Sparkle_ wsl],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/116/202204260557481037.html

Random recommended