Apache和Tomcat 实现泛域名解析的尝试

服务器搭建日记(三):以Apache-Tomcat方式提供服务 Apache服务配置。 阅读详情

原文:http://www.java2000.net/viewthread.jsp?tid=5422

你想让自己的服务器为每个会员提供一个独立的二级域名吗?比如
aa.test.com
bb.test.com/blog
当然aa、bb都是你的一个会员而已

下面是我今天尝试成功的部分

1 安装apache ,tomcat 和 mod_jk部分我就不说了,如果你不能使用它们,请参考其它教程

2 相关的配置文件

httpd.conf

 
# 去掉这个前面的#
, 启用它
LoadModule rewrite_module modules/mod_rewrite.so
 
# 启用jk
, 同时配置参数
LoadModule   jk_module   modules/mod_jk.so       
JkWorkersFile   D:/Apache2
.2 /conf/workers.properties     
JkLogFile   d:/Apache2
.2 /logs/mod_jk.log     
JkLogLevel   info   
#JkLogLevel   debug     
JkLogStampFormat   
" [%a   %b   %d   %H:%M:%S   %Y]    "      
JkOptions   +ForwardKeySize   +ForwardURICompat   -ForwardDirectories     
JkRequestLogFormat   
" %w   %V   %T "      
JkMount   /servlet/*   myloadbalancer   
JkMount   /*.jsp   myloadbalancer
 
# 虚拟主机,这里模拟了 a.test.com 和 b.test.com 以及 a.tst.com/blog的调用
 
<VirtualHost _default_:
80 >
ServerAdmin yourmail@domain.com
DocumentRoot D:Apache2
.2 htdocs
ServerName all-sites
ErrorLog logs/all-sites-error.log
CustomLog logs/all-sites-access.log common
RewriteEngine On
# 下面四行实现动态解析
RewriteCond %{HTTP_HOST} ^
[ a-z0-9- ] +.test.com$
RewriteRule ^/(.*)$ /%{HTTP_HOST}/$
1
RewriteRule ^/(
[ a-z0-9- ] +).test.com/?$ /index.jsp?u = $ 1   [ L,PT ]
RewriteRule ^/(
[ a-z0-9- ] +).test.com/blog(/(.*))?$ /blog.jsp?u = $ 1 &$ 3   [ L,PT ]

<Directory 
" D:Apache2.2htdocs " >
    Options FollowSymLinks
    AllowOverride None
    Order allow
, deny
    Allow from all
</Directory>

</VirtualHost>

workers.properties

  worker.list = myloadbalancer   
    
  worker.tomcat1.type
= ajp13   
  worker.tomcat1.host
= localhost   
  worker.tomcat1.port
= 8009    
  worker.tomcat1.lbfactor
= 1    
      
    
  worker.myloadbalancer.type
= lb   
  worker.myloadbalancer.balance_workers
= tomcat1   
  worker.status.type
= status  

server.xml 
去掉前后的<!-- 和 -->启用 8009端口

  < Connector  port ="8009"  
...

3 说明一下

在httpd.conf里面启用了rewrite_module,和 mod_jk, 并配置了 与tomcat的连接配置。

虚拟主机的配置是关键

ServerName all-sites
可以修改为
ServerName test.com
ServerAlias *.test.com
这样可以明确指定这个虚拟主机负责的域名

urlRewrite 配置部分

  1. RewriteCond %{HTTP_HOST} ^[a-z0-9/-]+/.test/.com$   
  2. RewriteRule ^/(.*)$ /%{HTTP_HOST}/$1  
  3. RewriteRule ^/([a-z0-9/-]+)/.test/.com/?$ /index.jsp?u=$1 [L,PT]   
  4. RewriteRule ^/([a-z0-9/-]+)/.test/.com/blog(/(.*))?$ /blog.jsp?u=$1&$3 [L,PT]   

第一行,声明这个重写只对主机名(%{HTTP_HOST}) 类似 XXXX.test.com  感兴趣,那个是正则的

第二行,将所有的对此域名的请求进行第一次改写,比如
a.test.com 改成
/a.test.com

把
b.test.com/blog 改成
/b.test/com/blog

第三行,对无参数的访问进行调整
将 /a.test.com 改成
/index.jsp?u=a

第四行,对有参数路径的进行调整
将 /b.test.com/blog 改成
/blog.jsp?u=b

如果还有参数比如
b.test.com/id=3 则最终改写为
/b.test.com/id=3
/blog.jsp?u=b&id=3

剩下的就不多说了!







<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
apache+tomcat域名泛解析 立即下载

相关推荐

芯片设计-信号完整性 SI 解析:Unit Interval 与比特周期的关系及其在高速信号中的应用

本文深入解析了芯片设计中信号完整性(SI)的核心概念Unit Interval(UI)与比特周期的关系及其在高速信号中的应用。通过实际案例和计算公式,详细阐述了UI在不同数据速率下的变化、在眼图分析中的关键作用,以及如何应对高速信号设计中的抖动和码间干扰等挑战。文章还提供了PCB布线和芯片设计中的UI优化技巧,帮助工程师提升高速信号设计的实战能力。

weixin_28683391的博客 475

解析无限个二级域名的方法

解析无限个二级域名的方法有三种:无论使用哪种,都必须使用域名泛解析。将*.test.com(此处我们test.com作例子)解析到你指定的服务器上。如:*.test.com222.222.222.222注:作域名泛解析前,必须确认域名服务商对你提供域名泛解析服务。否则,后面的工作都是徒劳的。方法一:使用Windows自带DNS解析。步骤:1,添加好test.com,如下图2,在tes...

daxun5508的博客 1537

一分钟理解 AP(Affinity Propagation) 亲和⼒传播算法

这篇博客发出来后,我用 Rust 复现代码出现问题。为此,我对对照了 sklearn 的相关代码,反复比较了两天,发现一处 bug,把 += 误写成了 =,导致数据量大的时候完全无法聚类。这个debug过程让我仔细梳理的 AP 算法的计算过程,今天我对这篇博客做了大规模修改,以便能原样展现原论文思想。

程序猿视角 3226

Apache Tomcat 泛域名解析

Apache与Tomcat的结合在此就不赘述,详情可参考我写的博客 直入正题: 原理:tomcat不支持泛域名,但Apache支持,所以在此主要借助于Apache的泛域名支持,但tomcat与Apache结合这块,就和原来的Apache和Tomcat的结合不同了,Tomcat主要借助于在server.xml中有个&lt;Engine defaultHost="localhost" name=...

Jay Chang 601

从维纳滤波到Richardson-Lucy:图像去模糊算法的原理与实践

本文深入解析了图像去模糊的核心原理,重点对比了维纳滤波与Richardson-Lucy两种经典去卷积算法。维纳滤波在频域进行快速权衡,适用于高斯噪声场景;而Richardson-Lucy算法基于泊松噪声模型迭代优化,更适用于天文、显微等科学成像。文章通过Python代码实践,详细阐述了PSF(点扩散函数)的关键作用及算法选型指南。

weixin_29285605的博客 390

VulnHub靶机渗透实战(详细思路讲解)

使用kali中的namp工具扫描开放端口,这时kali会用一个端口号向目标主机的65535个端口发送TCP连接建立请求,回应了ack=1,syn=q的端口就是开放端口号,这里可以看到21,22,80,3306号端口是开放的。可以看到这里得到了很多哈希,带*号的是禁用的或者是空密码,将三个不带星号的密码复制下来,创建一个shell.txt文档,将三个密码复制进去。这里看到我们是没有成功进入这个网页的,应该是目录的问题,我们将目录修改一下,但是没有显示出来,可能是编码问题,再回到我们找到的源码。

weixin_65891791的博客 2553

nginx+tomcat 多域名的泛解析处理思路

在日常工作中,我们可能会碰到这样的需求,a.xx.com b.x...

weixin_33788244的博客 270

基于 STM32 的全自动洗车监控系统设计与实现

本文提出一种基于 STM32F103RCT6 芯片的全自动洗车监控系统方案,通过多传感器融合与智能控制算法,实现车辆检测、洗车流程自动化及状态远程监控。系统集成硬件选型、电路设计、软件流程及通信功能,可广泛应用于智能洗车场景。

weixin_42300449的博客 971

tomcat二级域名泛解析

遇到这种需求二级域名泛解析,应用服务器只有tomcat,在网上大概搜了下,发现都是Apache+Tomcat域名解析,既然没有就自己研究吧~~ (filter什么的就不说了) 好像tomcat不支持域名泛解析(*.xxx.com),但tomcat默认将不能解析的域名扔给&lt;Engine name="Catalina" defaultHost="localhost"&gt;,也就是说把loc...

lpluck08的专栏 420

数仓建模—数据治理框架选型

全名主要亮点覆盖面最广:从数据治理、架构、质量、安全到元数据、主数据、数据仓库等等,几乎所有数据管理主题都能在DMBOK里找到相应章节。概念权威统一:帮助组织建立通用术语和知识基础,减少“部门之间说法不一致”的沟通成本。适用场景:如果你所在公司(或团队)正准备系统梳理数据管理的方方面面,DMBOK是一份非常全面的指导手册,尤其适合培养新人或为整个组织统一认知。需要注意:DMBOK偏“知识指引”,不直接提供成熟度模型或实施路线图。想要落地,还需要结合其他评估模型或项目管理方法。小案例举例:某。

2401_84052244的博客 4748

三种方式实现电脑端同时登陆多个微信

现在越来越人都有两个甚至多个微信号,有时候我们需要登录在电脑回复消息,那么怎样才能在一个电脑上同时登录两个微信甚至是多个微信号(微信多开)呢?希望下列三种方法能对各位博友有帮助。 方法一:微信网页版实现 我们知道,目前网页版微信还是可以使用的。所以,我们可以利用多个浏览器来实现在同一台电脑上登录两个或多个微信的目的。 1.首先,我们在浏览器的搜索栏输入“微信网页版”,点击搜索并点开搜索到的带“官网”标志的链接进入网页版微信。 2.打开另外一个浏览器,比如刚才打开的是自己安装的第三方浏览器,那么我们再打开W

清平乐的技术专栏 1万+

java 泛域名_Apache和Tomcat 实现泛域名解析的尝试

Apache和Tomcat 实现泛域名解析的尝试你想让自己的服务器为每个会员提供一个独立的二级域名吗?比如aa.test.combb.test.com/blog当然aa、bb都是你的一个会员而已下面是我今天尝试成功的部分1 安装apache ,tomcat 和 mod_jk部分我就不说了,如果你不能使用它们,请参考其它教程2 相关的配置文件httpd.conf# 去掉这个前面的#,启用它LoadM...

weixin_39757122的博客 189

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

Apache和Tomcat实现泛域名解析的配置尝试

Apache和Tomcat实现泛域名解析的配置尝试,你想让自己的服务器为每个会员提供一个独立的二级域名吗?比如aa.test.com bb.test.com/blog 当然aa、bb都是你的一个会员而已 [color=red]/**本来复制与http://www.itwis.com/html/java/javarest/20080521/1523.html*/[/color] 1 安装ap...

houjiang2100_163_com的专栏 276

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

Apache和Tomcat 实现泛域名解析的尝试[转]

你想让自己的服务器为每个会员提供一个独立的二级域名吗?比如 aa.test.com bb.test.com/blog 当然aa、bb都是你的一个会员而已 下面是我今天尝试成功的部分 1 安装apache ,tomcat 和 mod_jk部分我就不说了,如果你不能使用它们,请参考其它教程 2 相关的配置文件 httpd.conf # 去掉这个前面的#,启用它 Load...

weixin_30667649的博客 112

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

IIS与tomcat需共用80端口(单IP)的尝试

工作中遇到IIS与tomcat需共用80端口(单IP),按网上的帖子试了N遍未果。后咨询高人,用apache做代理实现了。   1. 网站web1配置IIS使用端口81,启动IIS 注意: 记住设置完成后要停止服务后重启,并用浏览器测试用"http://网站服务器局域网IP:81"可以正常访问 2. 网站web2配置Tomcat下面的server.xml配置文件,使用端口8081并重启T

专注云计算与互联网 677

URL重写的几种实现方式的总结(2)

Apache 2.2 + Tomcat 使用UrlRewrite实现泛域名解析的尝试 1 安装 tomcat/apache 2 下载 jk.so, 具体版本请根据需要,不再多说 3 关键是配置 httpd.conf Code 1 2 # 去掉这个前面的#,启用它 3 LoadModule rewrite_module modules/mod_rewrite.s...

mickwlp 166

linux系统Tomcat服务器绑定多个域名,改80端口教程

1、解析域名 首先您可能需要购买一个域名,然后再域名管理那里,点击“域名解析”,添加解析, 选则A记录,设置好要解析的域名,和你的linux系统所在的外网IP 所谓顶级域名就是域名主体前面没有前缀(www除外)的,如: http://pwdgame.com/ http://www.pwdgame.com/ 所谓二级域名就是就是含有前缀的,如: http://cctv.pwdgame....

键盘的起始页 4613

Apache 配置 WebSocket 协议

本文使用 http proxy 方式 实现 apache 支持 WebSocket 请求(JK 使用的 ajp 协议不能支持websocket) 通过 apache 访问 后端 tomcat上的 websocket 服务,需要使用 mod_proxy.so 和 mod_proxy_wstunnel.so两个库文件(在apache2.4 安装目录下已存在,放开httpd.conf文件中的注释即可...

weixin_30301183的博客 259
上一篇: 2008年5月19日14:28,Java非技术版祝福分的汇总
下一篇: Eclipse使用Axis生成WebService客户端的过程
老紫竹
博客等级 码龄19年 1万+粉丝 1252原创
评论 4
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址