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

相關文章
相關標籤/搜索
本站公眾號
   歡迎關注本站公眾號,獲取更多信息