Nginx在windows下的使用嘗試

Nginxwindows下的使用

 

下載 nginx-1.6.0,解壓到任意Ipanema目錄即可

 

1.配置:

/conf/  添加 代理 和解壓縮 配置(proxy.conf ,gzip.conf

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 300;  

proxy_send_timeout 300;  

proxy_read_timeout 300;  

proxy_buffer_size 4k;  

proxy_buffers 4 32k;  

proxy_busy_buffers_size 64k;  

proxy_temp_file_write_size 64k;

gzip.conf 內容:

gzip              on;    

gzip_min_length   1024;    

gzip_buffers      4 8k;    

gzip_comp_level   9;    

gzip_proxied      any;    

gzip_types        application/xml application/javascript application/x-javascript application/atom+xml application/rss+xml;    

gzip_types        text/css  text/javascript text/js text/plain text/xml;  

 

*gzip_types 默認適配text/html 可不加,如果在此處報錯,***掉text/html即可。

 

2./conf/nginx.conf 下,修改文件。

proxy.conf ,gzip.conf添加進來

http{

... ...

include    gzip.conf;  

include    proxy.conf; 

 

#添加一些設置

client_header_timeout  3m;  

client_body_timeout    3m;  

send_timeout           3m;  

client_header_buffer_size    1k;  

 

large_client_header_buffers  4 4k;  

 

... ...

}

 

 

3.一臺服務器,多個tomcat的切換

http{

......

upstream localhost {  

#weigth參數表示權值,權值越高被分配到的機率越大  

server localhost:28080 weight=1;  

server localhost:18080 weight=2;  

...

 

}

......

Server{

listen       80;

        server_name  www.xxxcom;  #本地可以監測localhost

index index.jsp index.htm index.do index.action;

root  XXX; #web的工作目錄 

        #charset koi8-r;

 

        #access_log  logs/host.access.log  main;

 

        location / {

            root  xxx;

            index  index.html index.jsp;

        }

 

}

 

}

 

本地開啓多個tomcat,使用默認的配置即可。

nginx文件下cmd   start nginx開啓進程即可

Nginx -s stop關閉

 

4.一個服務器,多個站點的去端口訪問

配置兩個server{} http{}裏面

server_name 填寫網站名稱

Index 訪問的主頁名稱index.html index.htm index.jsp...

root 站點目錄地址

重啓nginx即可訪問。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章