Centos6.5 Nginx +Tomcat 集群搭建解析

不点 阅读:229 2021-03-31 21:50:19 评论:0

系统资源:

nginx    一台

Tomcat +JDK 两台


第一步:CentOs 6.5 安装Nginx 详细步骤:请参考centos 6.5 搭建nginx

第二步:CentOs6.5 安装Tomcat +JDK 详细步骤:请参考CentOs 6.5 搭建Tomcat   + CentOs6.5 搭建JDK

第三步:修改Nginx的配置文件,我的nginx 配置文件位置(cd /usr/local/webserver/nginx/nginx.conf)

 

#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 { 
    use epoll; 
    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; 
     
    upstream servers{ 
	server 120.25.56.93:8080; 
	server 120.25.58.50:8080;   
	} 
    #gzip  on; 
 
    server { 
        listen       8084; 
        server_name  120.76.112.207; 
 
        #charset koi8-r; 
 
        #access_log  logs/host.access.log  main; 
 
        location / { 
           proxy_pass  http://servers; 
	   proxy_set_header Host $host; 
	   proxy_set_header X-Real-IP $remote_addr; 
	   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
        } 
 
        #error_page  404              /404.html; 
 
        # redirect server error pages to the static page /50x.html 
        # 
        error_page   500 502 503 504  /50x.html; 
        location = /50x.html { 
            root   html; 
        } 
 
        # proxy the PHP scripts to Apache listening on 127.0.0.1:80 
        # 
        #location ~ \.php$ { 
        #    proxy_pass   http://127.0.0.1; 
        #} 
 
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 
        # 
        #location ~ \.php$ { 
        #    root           html; 
        #    fastcgi_pass   127.0.0.1:9000; 
        #    fastcgi_index  index.php; 
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name; 
        #    include        fastcgi_params; 
        #} 
 
        # deny access to .htaccess files, if Apache's document root 
        # concurs with nginx's one 
        # 
        #location ~ /\.ht { 
        #    deny  all; 
        #} 
    } 
 
 
    # another virtual host using mix of IP-, name-, and port-based configuration 
    # 
    #server { 
    #    listen       8000; 
    #    listen       somename:8080; 
    #    server_name  somename  alias  another.alias; 
 
    #    location / { 
    #        root   html; 
    #        index  index.html index.htm; 
    #    } 
    #} 
 
 
    # HTTPS server 
    # 
    #server { 
    #    listen       443 ssl; 
    #    server_name  localhost; 
 
    #    ssl_certificate      cert.pem; 
    #    ssl_certificate_key  cert.key; 
 
    #    ssl_session_cache    shared:SSL:1m; 
    #    ssl_session_timeout  5m; 
 
    #    ssl_ciphers  HIGH:!aNULL:!MD5; 
    #    ssl_prefer_server_ciphers  on; 
 
    #    location / { 
    #        root   html; 
    #        index  index.html index.htm; 
    #    } 
    #} 
 
} 
第四步:重新启动ngixn

[root@iZ94phz01rnZ sbin]# ./nginx -s reload 
[root@iZ94phz01rnZ sbin]# ./nginx -s reopen 

第五步:相关效果截图:


声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

发表评论
搜索
排行榜
KIKK导航

KIKK导航

关注我们