void

          用nginx+tomcat來代替apache+jk+tomcat


          vi /usr/local/nginx/conf/nginx.conf 

          給出一些主要更改的地方 
          user  nobody nobody; 
          worker_processes  2; 
          error_log  logs/error.log  notice; 
          pid        logs/nginx.pid; 
          events { 
              worker_connections  1024; 

          http { 
              include       mime.types; 
              default_type  application/octet-stream; 
              include    /usr/local/nginx/conf/proxy.conf; 
          #上面這行是增加的 
              server { 
                  listen       81; 
                  server_name  localhost;   
                  charset gb2312; 
          # serve static files 
                  location ~ ^/(images|pages|javascript|js|css|flash|media|static)/  { 
                          root    /usr/local/www; 
                          expires 30d; 
                  location / { 
                      root /usr/local/www;            
                      index  index.jsp index.htm; 
                      proxy_pass http://192.168.1.250:8080; 
                    } 

          location /NginxStatus { 
                                  stub_status             on; 
                                  access_log              on; 
                                  auth_basic              "NginxStatus"; 
                          } 


          說明配置文件中有提到proxy.conf 這個文件可以VI一個如下文件 
          [root@test conf]# cat proxy.conf  
          #!nginx (-) 
          # proxy.conf 
          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_buffers           32 4k; 
          測試配置文件 
          [root@test conf]# /usr/local/nginx/sbin/nginx -t 
          2008/05/04 15:40:02 [info] 2363#0: the configuration file /usr/local/nginx/conf/nginx.conf syntax is  

          ok 
          2008/05/04 15:40:02 [info] 2363#0: the configuration file /usr/local/nginx/conf/nginx.conf was tested  

          successfully 
          啟動 
          [root@test conf]# /usr/local/nginx/sbin/nginx 
          [root@test conf]# ps fax 
          9400 ?        Ss     0:00 nginx: master process /usr/local/nginx/sbin/nginx 
           9401 ?        S      0:00  \_ nginx: worker process       
           9402 ?        S      0:00  \_ nginx: worker process   

          http://192.168.1.250:81/NginxStatus 
          Active connections: 1  
          server accepts handled requests 
          2 2 11  
          Reading: 0 Writing: 1 Waiting: 0    


          http://192.168.1.250:81就可以訪問我的頁面了用著個nignx+tomcat來替代apache+jk+tomcat 
          同樣的可以讓squid來監聽80端口 這樣就透明代理了 
          查看服務器信息 
          [root@test conf]# curl -I http://localhost 
          HTTP/1.0 200 OK 
          Server: nginx/0.6.26 
          Date: Sun, 04 May 2008 07:18:27 GMT 
          Content-Type: text/html;charset=GBK 
          Set-Cookie: JSESSIONID=0CE2D90115EFDE9830215A55414BF11F; Path=/ 
          X-Cache: MISS from test.suantop.com 
          Via: 1.0 test.abc.com (squid/3.0.STABLE2) 
          Connection: close

          posted on 2008-08-06 14:59 void 閱讀(729) 評論(0)  編輯  收藏 所屬分類: Nginx

          主站蜘蛛池模板: 来宾市| 赤壁市| 河北省| 沁源县| 长白| 兖州市| 祁连县| 瑞安市| 嵊州市| 上思县| 湖北省| 黎川县| 休宁县| 鹰潭市| 青川县| 濮阳县| 敖汉旗| 维西| 绵阳市| 仁寿县| 温州市| 洛扎县| 讷河市| 商南县| 湘潭县| 元江| 章丘市| 申扎县| 金山区| 都匀市| 布尔津县| 三门峡市| 合水县| 敦化市| 淮阳县| 平原县| 大田县| 明溪县| 通化市| 四子王旗| 公安县|