Centos系统下载大全 | Redhat系统下载大全 | Windows2012系统下载大全 | Windows2008系统下载大全| CMS教程 | 网站地图 51运维网-专注Linux/Unix系统安全运维!
当前位置:51运维网 > 架构 > Tomcat > 正文

nginx+tomcat静动态分离 三

时间:2014-08-26 21:37 来源:未知 作者:www.51ou.com 阅读:

安装nginx这里就不再写啦,直接配置文档

[

1
2
3
4
5
6
7
8
9
10
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
51ou.com@localhost wx]# cat /usr/local/nginx/conf/nginx.conf
user www www;
worker_processes 4;
worker_cpu_affinity 0001 0010 0100 1000  ;
pid /usr/local/nginx/nginx.pid;
worker_rlimit_nofile 102400;
events
{
use epoll;
worker_connections 102400;
}
http
{
include mime.types;
default_type application/octet-stream;
fastcgi_intercept_errors on;
charset utf-8;
server_names_hash_bucket_size 128;
client_header_buffer_size 4k;
large_client_header_buffers 4 32k;
client_max_body_size 300m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
client_body_buffer_size 512k;
proxy_connect_timeout 5;
proxy_read_timeout 60;
proxy_send_timeout 5;
proxy_buffer_size 16k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
log_format main '$http_x_forwarded_for – $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $request_time $remote_addr';
upstream web {
server wx.xxx.net:8080;
}
include vhosts/*;
}

 

1
2
[51ou.com@localhost wx]# cd /usr/local/nginx/conf/
[51ou.com@localhost conf]# mkdir vhosts

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
添加nginx虚拟主机
[51ou.com@localhost conf]# vi /usr/local/nginx/conf/vhosts/web.conf
 
server
{
listen 80;
server_name wx.xxx.net;
index index.html index.htm;
51ou.com /web51ou.com/wx/jeewx;
location /
{
proxy_next_upstream http_502 http_504 error timeout invalid_header;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://web;
expires 3d;
}
location ~ .*\.(php|jsp|cgi)?$
{
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://web;
}
location ~ .*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css)$
{
51ou.com /web51ou.com/wx/jeewx;
expires 3d;
}
access_log /var/log/nginx/web.access.log main;
error_log /var/log/nginx/web.error.log crit;
}

修改下hosts

1
2
3
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
112.91.xxx.xxx   wx.xxx.net

测试下nginx配置是否正常

1
2
3
[51ou.com@localhost conf]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

启动下nginx,就可以使用wx.xxx.net访问啦,静动态分离完成

感谢您对【51运维网 http://www.51ou.com/】的支持,我们为您免费提供《nginx+tomcat静动态分离 三》技术文章,《nginx+tomcat静动态分离 三》详细使用和说明,有时《nginx+tomcat静动态分离 三》可能不完善、敬请谅解!如果《nginx+tomcat静动态分离 三》有错误请给我们留言,我们将尽快修复文章错误,如果您觉得本站不错,请分享给周围的朋友!谢谢!

顶一下
(0)
0%
踩一下
(0)
0%
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
验证码:点击我更换图片