Linux安全网 - Linux操作系统_Linux 命令_Linux教程_Linux黑客

绿色网站无广告
会员投稿 投稿指南 本期推荐:
搜索:
您的位置: Linux安全网 > Linux集群 > Architecture > » 正文

apache+tomcat配置动态二级域名

来源: zp820705 分享至:

apache2.2配置

编译要求支持的组件:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so

编辑主配置文件:conf/httpd.conf,再文件结尾加入:

ProxyRequests Off
ProxyPreserveHost on

打开虚拟主机配置的Include

#Include conf/extra/httpd-vhosts.conf

修改为:

Include conf/extra/httpd-vhosts.conf

编辑虚拟主机配置文件 vi conf/extra/http-vhost.conf

1.默认虚拟主机,使用ip或任意域名访问

# default host configuration for business and rm
<VirtualHost *:80>
  ErrorLog "logs/error_default.log"
  LogLevel warn
  CustomLog "logs/access_default.log" combinedio

  ProxyPass / balancer://cluster-busi/ stickysession=jsessionid nofailover=Off
  ProxyPassReverse / balancer://cluster-busi/
  # business ab+lb, Horizontal expansion of multiple business nodes
  <Proxy balancer://cluster-busi>
    BalancerMember  http://10.10.10.181:8013 loadfactor=5 retry=10
    BalancerMember  http://10.10.10.182:8013 loadfactor=5 retry=10
    ProxySet lbmethod=bybusyness
  </Proxy>
</VirtualHost>

2.域名访问

支持: http://www.domain.com 和http://username.domain.com

对于二级域名:http://username.domain.com先使用rewrite重写为:http://username.domain.com/username/,然后再使用proxy转发到下层的tomcat集群处理

# S3 configuration for dynamic domain name.
<VirtualHost *:80>
  ServerName www.oss.com
  ServerAlias *.oss.com

  ErrorLog "logs/error_s3.log"
  LogLevel warn
  CustomLog "logs/access_s3.log" combinedio

  RewriteEngine on
  RewriteLog "/opt/apache/logs/rewrite_s3.log"
  RewriteLogLevel 3
  RewriteCond %{HTTP_HOST} ^.+\.oss\.com$
  RewriteRule /(.*) /%{HTTP_HOST}/$1
  RewriteRule /(.+)\.oss\.com/(.*)$ /$1/$2 [PT]

  ProxyPass / balancer://cluster-s3/ nofailover=Off
  ProxyPassReverse / balancer://cluster-s3/
  <Proxy balancer://cluster-s3>
    BalancerMember  http://10.10.10.181:8013/oss loadfactor=5 retry=10
    BalancerMember  http://10.10.10.182:8013/oss loadfactor=5 retry=10
    ProxySet lbmethod=byrequests
  </Proxy>
</VirtualHost>

tomcat集群配置略。


Tags:
分享至:
最新图文资讯
1 2 3 4 5 6
验证码:点击我更换图片 理智评论文明上网,拒绝恶意谩骂 用户名:
关于我们 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 发展历史