Nginx基础

正向代理:代理客户端的 如vpn

反向代理:代理服务器的

常用命令

cd /usr/local/nginx/sbin/
./nginx  启动
./nginx -s stop  停止
./nginx -s quit  安全退出
./nginx -s reload  重新加载配置文件
ps aux|grep nginx  查看nginx进程

配置文件


http {
    
	upstream rainhey{      //rainhey是自定义的名称,用于location中引用
		server 127.0.0.1:8082/ weight=1;   //服务地址、端口    权重-比例,可以用来设置负载均衡
		server 127.0.0.1:8081/ weight=1;
	}
    
    server {
        listen       80;
        server_name  localhost;

        location / {			// nginx拦截所有 80端口的 /请求
            root   html;
            index  index.html index.htm;
			
			proxy_pass http://rainhey;     //  代理到rainhey服务列表中的服务
        }

 

posted @ 2022-06-18 11:02  qiaoyizhi  阅读(24)  评论(0编辑  收藏  举报