简单介绍一下他的安装及配置过程
官方网站
http://wiki.codemongers.com/Main
一、依赖的程序
1. gzip module requires zlib library
2. rewrite module requires pcre library
3. ssl support requires openssl library
二、安装
./configure
make
make install
默认安装的路径是/usr/local/nginx
更多的安装配置
./configure --prefix=/usr/local/nginx
--with-openssl=/usr/include (启用ssl)
--with-pcre=/usr/include/pcre/ (启用正规表达式)
--with-http_stub_status_module (安装可以查看nginx状态的程序)
--with-http_memcached_module (启用memcache缓存)
--with-http_rewrite_module (启用支持url重写)
三、启动及重启
启动:nginx
重启:kill -HUP `cat /usr/local/nginx/logs/nginx.pid`
测试配置文件:nginx -t
简单吧,安装,启动都比较方便。
四、配置文件
http://wiki.codemongers.com/NginxFullExample
#运行用户

2

3

4

5

6

7

8

9

10

#/dev/poll(高效模式,适用Solaris 7 11/99+, HP/UX 11.22+ (eventport), IRIX 6.5.15+ 和 Tru64 UNIX 5.1A+)
11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

#Deny access to any host other than (www).4535.com
server {
server_name _; #default
return 404;
}
55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

原文地址:http://www.blogjava.net/cenly60/archive/2008/12/12/245965.html
nginx可以很方便的配置成反向代理服务器
影响版本(nginx-1.0.10):
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://147.16.24.175:9500 ;
proxy_set_header Host $host:80;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Via "nginx";
}
}
但是如果nginx的监听端口不是默认的80端口,改为其他端口如81端口。
后端服务器中request.getServerPort()无法获得正确的端口,返回的仍然是80;
在response.sendRedirect()时,客户端可能无法获得正确的重定向url。
正确的配置方法为
在 $host之后加上端口号,如$host:81
server {
listen 83;
server_name localhost;
location / {
proxy_pass http://147.16.24.175:9500 ;
proxy_set_header Host $host:83;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Via "nginx";
}
}
原文地址:http://blog.sina.com.cn/s/blog_56d8ea9001012e09.html