Linux Nginx配置nginx.conf效率很高

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

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

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

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

Linux Nginx抓http包可看到request为

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

【编辑推荐】

  1. Linux Nginx安装编译MySQL 5.1.34扩展库及Php Web服务器
  2. Linux系统稳定性和安全性要更强
  3. Linux vsFTPD安装与配置文件和配置虚拟用户
  4. Linux MYSQL命令修改各种连接的这那方法
  5. Linux MySQL程序服务内建安全机制
责任编辑:佚名 来源: CSDN
相关推荐

2010-02-06 10:24:52

CentOS Ngin

2017-12-28 10:22:28

NginxFastCGIPHP-fpm

2022-07-12 17:24:48

NginxDocker

2024-10-17 16:30:28

2020-06-18 09:10:10

开源技术 Nginx

2010-03-30 15:25:42

Linux Nginx

2024-11-15 10:58:40

2013-06-05 13:31:25

2024-06-13 10:16:29

2014-03-28 14:20:04

2019-09-09 11:02:17

Nginx进程模型

2010-02-06 14:00:05

Linux Nginx

2011-11-28 22:18:53

Nginxtomcat集群

2024-03-26 12:08:20

加密NginxHTTP

2011-11-28 15:26:40

Nginx配置

2023-08-30 08:51:41

NginxLinux

2010-03-30 18:56:13

Nginx配置模块

2019-08-25 07:15:47

Nginx防盗链Linux

2014-07-28 11:37:49

NginxTomcat

2014-04-29 14:54:48

Nginx反向代理
点赞
收藏

51CTO技术栈公众号