nginx+tomcat求助

溟溟 发布于 2013/04/17 14:14
阅读 199
收藏 2

  以下是我nginx配置;


#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;
    upstream control-center {
  server localhost:8080;
  server localhost:8081;
  ip_hash;
 }


    server {
        listen       80;
        server_name  control-center;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
     proxy_pass                  http://control-center
           proxy_redirect              off;
           proxy_set_header            Host $host;
           proxy_set_header            X-Real-IP $remote_addr;
           proxy_set_header            X-Forwarded-For $proxy_add_x_forwarded_for;
           client_max_body_size        10m;
           client_body_buffer_size     128k;
           proxy_connect_timeout       90;
           proxy_send_timeout          90;
           proxy_read_timeout          90;
           proxy_buffer_size           4k;
           proxy_buffers               4 32k;
           proxy_busy_buffers_size     64k;
           proxy_temp_file_write_size  64k;

        }

        #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;
    #    server_name  localhost;

    #    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_timeout  5m;

    #    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
    #    ssl_prefer_server_ciphers   on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

 

完成之后只有一个8080端口的有效果~~~求解答~~~~~~~~~~

 

加载中
0
红薯
红薯
ip_hash 这一行去掉
溟溟
溟溟
@loyal @loyal windows XP 我确定nginx重启了
loyal
loyal
回复 @溟溟 : 1.你不是windows吧?2.确定nginx重启了?进程结束了?
溟溟
溟溟
@loyal @loyal 也已经重启了,因为我启动两个tomcat,把tomcat1停掉之后,刷新页面就再也不好使了!~~~
loyal
loyal
回复 @溟溟 : 去掉后,你要重启nginx,然后不停的刷页面,有几率的会跳到另一个tomcat.
溟溟
溟溟
@红薯 tomcat2依然不好使啊~~
0
疯狂的艺术家
疯狂的艺术家

会话粘滞住了 

@红薯 老大说的对。

溟溟
溟溟
@木叶飞舞 停掉tomcat1之后也访问不了tomcat2
返回顶部
顶部