CentOS Nginx服务器配置nginx.conf

系统 Linux
由于项目目前只有一台CentOS Nginx 的服务器,无法用来测试,所以打算找下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台服务器CentOS Nginx

在向大家详细介绍CentOS Nginx之前,首先让大家了解下CentOS Nginx,然后全面介绍CentOS Nginx,希望对大家有用。CentOS Nginx 已经是目前公认的效率很高的代理服务,同时可以用来做负载均衡。

由于项目目前只有一台CentOS Nginx 的服务器,无法用来测试,所以打算找下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台服务器CentOS Nginx

配置CentOS 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.  
  8. listen 80;  
  9.  
  10. server_name sp.imichat.com;  
  11. #charset koi8-r;  
  12. #access_log logs/host_access_log main;  
  13.  
  14. location / {  
  15. proxy_pass http://sp.imichat.com;  
  16. proxy_set_header Host $host;  
  17. proxy_set_header X-Real-IP $remote_addr;  
  18. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;  
  19. }  
  20.  
  21. access_log logs/sp.imichat.com.log combined;  
  22. [/code] 

启动181上的3个tomcat,修改tomcat首页加入端口信息,以用来清晰看到当前分配到那台tomcat启动Nginx,访问 http://sp.imichat.com/可看到请求被发送到3台服务器。

抓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=A75E09D2EBF769A7BD95195E29DE87DEkey=1227008000183memberName=adminmemberType=%7C%u8D85%u7EA7%u7BA1%u7406%u5458%7C  
  11. Pragma: no-cache  
  12. Cache-Control: no-cache 

response:

  1. HTTP/1.1 200 OK  
  2. Server: nginx/0.7.21-win32  
  3. Date: Tue, 18 Nov 2008 12:12:33 GMT  
  4. Content-Type: text/html  
  5. Connection: keep-alive  
  6. ETag: W/"8157-1227009260637"  
  7. Last-Modified: Tue, 18 Nov 2008 11:54:20 GMT  
  8. Content-Length: 8157 

【编辑推荐】

  1. CentOS yum仓库使用 ISO 文件制作
  2. CentOS VM主机支持RedHat AS3/AS4/AS5Linux操作系统
  3. CentOS系统CPU过热处理的解决方法
  4. CentOS bonding技术使用奇怪的拓扑结果
  5. CentOS CPU使用率查看相应信息分析系统状况
责任编辑:佚名 来源: CSDN
相关推荐

2010-02-04 14:15:05

Linux Nginx

2021-07-28 23:32:09

Nginx服务器Https

2020-04-15 20:57:57

NginxWeb服务器

2021-11-24 08:00:00

服务器Web系统

2019-12-24 14:42:51

Nginx服务器架构

2020-05-12 21:17:18

Nginx服务器架构

2019-01-10 11:12:15

Nginx服务器架构

2019-09-10 15:22:17

Nginx服务器架构

2017-03-06 09:26:56

Nginx服务器 SSL

2010-03-30 14:35:58

Nginx反向代理

2018-08-21 08:49:53

Nginx服务器配置

2021-01-29 14:41:43

Nginx直播服务器rtmp

2018-02-08 08:52:37

2013-12-17 09:42:53

Nginx性能分析http服务器

2018-02-27 11:08:11

2021-09-10 10:07:17

Nginx虚拟主机服务器

2017-12-27 10:18:09

ApacheNginx服务器

2010-03-24 19:21:55

Nginx服务器

2019-01-14 10:27:50

服务器Node 项目前端

2009-08-19 13:57:13

telnet服务器配置
点赞
收藏

51CTO技术栈公众号