Nginx

1617698655247

什么是Nginx?

Nginx是一个高性能的http和反向代理web服务器。

特点:占有内存少(约1mb,却能支持5万高并发),并发能力强。

Nginx的作用:

1 提供负载均衡。(能够做到iphash,session共享。)

2 http代理,反向代理。

3 动静分离,提升访问速度。

下载:http://nginx.org/en/download.html

img

img

配置 upstream来负载均衡

 upstream seckill{

​    	server 192.168.226.1:8070 weight=1;

​	server 192.168.226.1:8080 weight=1;

​	server 192.168.226.1:8090 weight=1;

 

​    }

​    

​    server {

​        listen       80;

​        server_name  localhost;

 

​        \#charset koi8-r;

 

​        \#access_log  logs/host.access.log  main;

 

​        location / {

​            root   html;

​            index  index.html index.htm;

​	    proxy_pass http://seckill;

​	    proxy_set_header Host $host:$proxy_port;

​	    

​        }

注意:在nginx.conf文件中配置反向代理的后,重启nginx不生效.

原因:后台有许多nginx进程

解决办法:关闭所有进程,然后再重启nginx

通过命令行的方式,在nginx安装路径下输入:

(1)taskkill /IM nginx.exe /F 去关闭所有nginx进程。

(2)start nginx 重启nginx

图片说明