首页 > 其他 > 详细

nginx,LNMP部署

时间:2019-06-16 13:20:25      阅读:98      评论:0      收藏:0      [点我收藏+]

nginx功能:

(1)web服务器:

默认网页目录为:/usr/share/nginx/html

 

(2)反向代理服务器:

       nginx代替客户端访问后端服务器,后端服务器只知道是nginx的请求,并将结果返回给 nginx,nginx 在返回给客户端结果

找到nginx配置文件中 location,配置段如下,默认是空的参数

location / {
}

做反向代理,/ 后面加上虚拟路径名字,下面用 proxy_pass 模块和上游的服务器的url,例如:

location /node1 {
        proxy_pass http://192.168.210.131/;
        }

 

(3)负载均衡服务器:

        nginx 负责转发客户端的请求,轮询到的后端服务器获得的是客户端的访问请求,服务器直接返回给客户端结果       先配置 location 中的反向代理,将客户端请求发送到一个集群(zn为集群名,可以随便起),然后用 upstream 模块声明集群,并写入后端的真实server的地址,例如:

    include /etc/nginx/conf.d/*.conf;
    upstream zn {
    server 192.168.210.132 weight=2 max_fails=2 fail_timeout=2;
    server 192.168.210.131 weight=1 max_fails=2 fail_timeout=2;
    }
    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        root         /usr/share/nginx/html;
        index        index.php index.html;
        # Load configuration files for the default server block.
#        include /etc/nginx/default.d/*.conf;

        location / {
        proxy_pass http://zn/;
        }

 

nginx,LNMP部署

原文:https://www.cnblogs.com/cloudhere/p/10946522.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!