Linux Nginx配置nginx.conf效率很高

來源:互聯網
上載者:User

Linux Nginx 還是比較常用的,於是我研究了一下Linux Nginx ,在這裡拿出來和大家分享一下,希望對大家有用。Linux Nginx 已經是目前公認的效率很高的代理服務,同時可以用來做負載平衡。由於項目目前只有一台centOS的伺服器,無法用來測試,所以打算找下Linux Nginx windows下版本;http://www.kevinworthington.com/nginx/win32/以上為win32的版本使用者訪問 sp.imichat.com 均衡到 10.10.10.181:8080; 10.10.10.181:8081; 10.10.10.181:8082; 這3台伺服器

配置Linux Nginx的nginx.conf

 
  1. http {}增加如下內容  
  2. upstream sp.imichat.com {   
  3. server 10.10.10.181:8080;   
  4. server 10.10.10.181:8081;   
  5. server 10.10.10.181:8082; }  
  6. server {} 修改異俠資訊:  
  7. listen 80;  
  8. server_name sp.imichat.com;  
  9. #charset koi8-r;  
  10. #access_log logs/host_access_log main;  
  11. location / {  
  12. proxy_pass http://sp.imichat.com;  
  13. proxy_set_header Host $host;  
  14. proxy_set_header X-Real-IP $remote_addr;  
  15. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;  
  16. }  
  17. access_log logs/sp.imichat.com.log combined;  
  18. [/code] 

Linux Nginx啟動181上的3個tomcat,修改tomcat首頁加入連接埠資訊,以用來清晰看到當前分配到那台tomcat啟動Linux Nginx,訪問 http://sp.imichat.com/可看到請求被發送到3台伺服器。

Linux Nginx抓http包可看到request為

 
  1. GET / HTTP/1.1  
  2. Host: sp.imichat.com  
  3. User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.4) Gecko/2008102920 Firefox/3.0.4  
  4. Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8  
  5. Accept-Language: en-us,zh-cn;q=0.5  
  6. Accept-Encoding: gzip,deflate  
  7. Accept-Charset: gb2312,utf-8;q=0.7,*;q=0.7  
  8. Keep-Alive: 300  
  9. Connection: keep-alive  
  10. Cookie: JSESSIONID=A75E09D2EBF769A7BD95195E29DE87DE; key=1227008000183;   
  11. memberName=admin; memberType=%7C%u8D85%u7EA7%u7BA1%u7406%u5458%7C  
  12. Pragma: no-cache  
  13. Cache-Control: no-cache 
 
  1. response:  
  2. HTTP/1.1 200 OK  
  3. Server: nginx/0.7.21-win32  
  4. Date: Tue, 18 Nov 2008 12:12:33 GMT  
  5. Content-Type: text/html  
  6. Connection: keep-alive  
  7. ETag: W/"8157-1227009260637"  
  8. Last-Modified: Tue, 18 Nov 2008 11:54:20 GMT  
  9. Content-Length: 8157 

  1. Linux Nginx安裝編譯MySQL 5.1.34擴充庫及Php Web伺服器
  2. Linux系統穩定性和安全性要更強
  3. Linux vsFTPD安裝與設定檔和配置虛擬使用者
  4. Linux MYSQL命令修改各種串連的這那方法
  5. Linux MySQL程式服務內建安全機制

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.