Window Nginx + JBoss 부하 배치 웹

5456 단어 window
얼마 전에 Nginx 를 알 아 보고 window 버 전 을 찾 아 설치 하 는 데 성 공 했 습 니 다.오늘 블 로 거 를 보 니 JBoss 와 WEB 를 통합 배치 하고 가능 하 다 면 프로젝트 에 사용 해 보 겠 다 는 생각 이 들 었 다.첫 접촉 은 잘못 을 면 하기 어렵다.
       1. Nginx 홈 페이지 에서 최신 안정 버 전 을 다운로드 하고 설치 배치 (생략...).
       2. Nginx 프로필 nginx - 1.8.0 \ conf 의 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 {
    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;
    #  JBoss  
    upstream localhost {
         server 127.0.0.1:8787;
	 server 127.0.0.1:8070;
    }
    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        #      location,    
	location / {    
		proxy_connect_timeout   3;  
		proxy_send_timeout      30;  
		proxy_read_timeout      30;  
		proxy_pass http://localhost;   
	} 
        #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;
    #    }
    #}

}

 
    프로필 은 한 곳 만 추가 하고 한 곳 만 수정 합 니 다.  
   1. upstream localhost 를 추가 하여 여러 개의 JBoss 를 설정 할 수 있 습 니 다. 전에 JBoss 포트 를 바 꾼 적 이 있 기 때문에 테스트 도 가 져 왔 습 니 다.
    
#  JBoss  
    upstream localhost {
         server 127.0.0.1:8787;
	 server 127.0.0.1:8070;
    }

 
  
   2. 원래 의 location 을 다음 과 같이 수정 합 니 다.
#      location,    
	location / {    
		proxy_connect_timeout   3;  
		proxy_send_timeout      30;  
		proxy_read_timeout      30;  
		proxy_pass http://localhost;   
	} 

 
  3. 정상적으로 웹 하 나 를 JBoss 에 배치 하면 저 는 웹 프로젝트 의 예 를 간단하게 썼 습 니 다. 프로젝트 이름 은 Nginx 1 입 니 다.
    index. jsp 의 내용 을 This is my JSP 1 페이지 로 수정 합 니 다. 포트 8787 인 JBoss 에 war 패키지 로 배치 하기;
    index. jsp 의 내용 을 This is my JSP 2 페이지 로 수정 합 니 다. 그리고 war 패키지 로 포트 8070 의 JBoss 에 배 치 됩 니 다.    가운데 4. 두 개의 JBoss 를 시작 하여 발 표 된 웹 프로젝트 에 문제 가 있 는 지 검증 합 니 다.
    1. 방문http://localhost:8787/Nginx1/index.jsp결 과 는 다음 그림 과 같 습 니 다. 문제 없습니다.
    2. 방문http://localhost:8070/Nginx1/index.jsp결 과 는 다음 그림 과 같 습 니 다. 문제 없습니다.
    두 방문 이 모두 정상 입 니 다. 그러면 우 리 는 지금부터 Nginx 프 록 시 를 사용 하면 어떻게 되 는 지 검증 합 니 다.
5. doc 를 사용 하여 Nginx 설치 디 렉 터 리 로 전환 하고 start nginx. exe 를 입력 하여 nginx 를 시작 하고 접근 합 니 다.    http://localhost/Nginx1/index.jsp, 첫 방문: (nginx 기본 감청 포트 는 80)
 다시 한 번 갱신:
 
 이로써 서로 다른 JBoss 서 비 스 를 상당히 방문 하 는 방식 으로 리 셋 하면 서비스의 스트레스 를 줄 이 고 부하 균형 을 이 룰 수 있다 는 큰 성 과 를 거 두 었 다.이 예 는 매우 간단 해서 입문 하여 이해 할 수 있 는 예 로 삼 을 수 있다. 
 

좋은 웹페이지 즐겨찾기