简单描述一下nginx两块网卡,eth1外网,eth0内网与tomcat eth0通信,用户请求静态内容由nginx直接响应,动态内容则nginx转发至后端tomcat响应
安装nginx,tomcat不再描述。
nginx的配置文件如下:/etc/nginx/nginx.conf
[root@node5 ~]# pnginx worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; location / { root html; index index.html index.htm; } location ~* \.(jsp|do)$ { proxy_pass http://172.16.251.23:8080; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }
访问测试,把相应的样式表,图片复制到nginx页面目录即可如下图:
1,介绍,apache(mod_proxy)+tomcat(安装配置简单,动静分离相对复杂,简单介绍反代动态资源)
tomcat安装不再描述。
安装apache
yum install httpd -y
通过http协议进行对后端的服务器的代理,配置如下:
新建并编配置文件: vim /etc/httpd/conf.d/mod_proxy.conf
[root@node5 conf.d]# cat mod_proxy.conf ProxyVia on ProxyRequests off ProxyPreserveHost on ProxyPass / http://172.16.251.24:8080/ ProxyPassReverse / http://172.16.251.24:8080/ <Location /> Order Allow,Deny Allow from all </Location>
也可以通过ajp协议进行对后端的服务器的代理,配置如下:
新建并编配置文件: vim /etc/httpd/conf.d/mod_proxy.conf
[root@node5 conf.d]# cat mod_proxy.conf ProxyVia on ProxyRequests off ProxyPreserveHost on ProxyPass / ajp://172.16.251.24:8009/ ProxyPassReverse / ajp://172.16.251.24:8009/ <Location /> Order Allow,Deny Allow from all </Location>
分别启动tomcat ,apache进行测试
2,介绍apache(mod_jk)+tomcat(ajp connectors) 代理通信的简单配置
安装apache
[root@node5 conf.d]yum install httpd httpd-devel -y [root@node5 software]# tar xf tomcat-connectors-1.2.37-src.tar.gz [root@node5 software]# cd tomcat-connectors-1.2.37-src/native/ [root@node5 native]# pwd /software/tomcat-connectors-1.2.37-src/native [root@node5 native]# which apxs /usr/sbin/apxs [root@node5 native]# ./configure --with-apxs=/usr/sbin/apxs [root@node5 native]#make && make install
查看安装下的connector module
编辑文件 /etc/httpd/conf.d/mod_jk.conf
[root@node5 conf.d]# cat mod_jk.conf LoadModule jk_module modules/mod_jk.so JkWorkersFile /etc/httpd/conf.d/workers.properties JkLogFile logs/mod_jk.log JkLogLevel notice JkMount /* Node4_TomcatA JkMount /status stat1
编辑文件 /etc/httpd/conf.d/workers.properties
[root@node5 conf.d]# cat workers.properties.bk worker.list=Node4_TomcatA,stat1 worker.Node4_TomcatA.type=ajp13 worker.Node4_TomcatA.port=8009 worker.Node4_TomcatA.host=172.15.251.24 worker.Node4_TomcatA.lbfactor=1 worker.stat1.type = status
配置完成可以进行测试
(nginx|apache)+tomcat 几种常见的代理实现方式或连接类型(connector type),布布扣,bubuko.com
(nginx|apache)+tomcat 几种常见的代理实现方式或连接类型(connector type)
原文:http://onlywyn.blog.51cto.com/204565/1409407