XN&Nginx负载均衡

 xupan003nginx

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

   #若是某一台服务器崩溃,nginx会将该崩溃的服务器从列表中移除,weight权重默认都是1
   upstream tomcats {
        server xupan001:8888 weight=1;
        server xupan001:8888 weight=1;
        server xupan001:8888 weight=1;
    }


   


    server {
        listen       80;
        server_name  xupan003;
       
        location ~ .* {
            proxy_pass http://tomcats;
        }

    }

}

[root@xupan003 nginx]# sbin/nginx -s reload    从新加载配置文件
[root@xupan003 nginx]# sbin/nginx -t    检查配置文件是否正确
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successfultomcat

 

启动:./sbin/nginx【默认会加载conf下的nginx.conf】   或者  ./sbin/nginx -c conf/nginx.conf服务器

[root@xupan003 nginx]# ps -ef | grep nginx
root       3444      1  0 02:34 ?        00:00:00 nginx: master process ./sbin/nginx -c conf/nginx.conf
nobody     3445   3444  0 02:34 ?        00:00:00 nginx: worker process          
nobody     3446   3444  0 02:34 ?        00:00:00 nginx: worker process          
nobody     3447   3444  0 02:34 ?        00:00:00 nginx: worker process          
nobody     3448   3444  0 02:34 ?        00:00:00 nginx: worker process          
root       3454   2729  0 02:34 pts/0    00:00:00 grep nginxapp

相关文章
相关标签/搜索
本站公众号
   欢迎关注本站公众号,获取更多信息