标签:
nginx.conf
user www www;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
use epoll;
worker_connections 1024;
}
http {
include mime.types;
default_type application
/octet-stream
;
server_tokens off;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
include
gzip
.conf;
server {
listen 80;
server_name localhost;
location / {
deny all;
}
location ~ ^
/NginxStatus
{
stub_status on;
access_log off;
allow 127.0.0.1;
allow 42.96.200.198;
deny all;
}
}
server {
listen 80;
server_name www.tojsp.com;
access_log logs
/tojsp
.log;
location ~ ^
/NginxStatus
{
stub_status on;
access_log off;
}
location ~ ^/(WEB-INF)/ {
deny all;
}
location ~ \.(gif|jpg|jpeg|png)$ {
root
/xdata/www/resource/tojsp
;
access_log off;
expires 24h;
}
location / {
proxy_pass http:
//localhost
:8080;
include proxy.conf;
}
}
server {
listen 80;
server_name it.tojsp.com;
access_log logs
/tojsp
.log;
location ~ ^
/NginxStatus
{
stub_status on;
access_log off;
}
location ~ ^/(WEB-INF)/ {
deny all;
}
location ~ \.(gif|jpg|jpeg|png)$ {
root
/xdata/www/resource/tojsp
;
access_log off;
expires 24h;
}
location / {
proxy_pass http:
//localhost
:8080;
include proxy.conf;
}
}
}
2. 再配置tomcat中的server.xml, 找到Host节点
server.xml
<
Host
name
=
"www.tojsp.com"
appBase
=
"/xdata/www/tojsp.com"
unpackWARs
=
"true"
autoDeploy
=
"true"
>
<
Context
path
=
""
docBase
=
"/xdata/www/tojsp.com"
reloadable
=
"true"
/>
</
Host
>
<
Host
name
=
"it.tojsp.com"
appBase
=
"/xdata/www/it.tojsp.com"
unpackWARs
=
"true"
autoDeploy
=
"true"
>
<
Context
path
=
""
docBase
=
"/xdata/www/it.tojsp.com"
reloadable
=
"true"
/>
</
Host
>
3.最后启动nginx与tomcat看看效果,是不是成功了。
标签:
原文地址:http://www.cnblogs.com/xzjie/p/4204747.html