<Service name="Catalina">
<!-- HTTP connector -->
<Connector port="80" redirectPort="443"/>
<!-- HTTPS connector -->
<!-- If the client does not use SNI it ends up with site1.example.net certificate -->
<Connector port="443" SSLEnabled="true" scheme="https" secure="true"
defaultSSLHostConfigName="site1.example.net">
<SSLHostConfig hostName="site1.example.net">
<Certificate certificateFile="conf/site1.example.net.crt" certificateKeyFile="conf/site1.example.net.key" />
</SSLHostConfig>
<SSLHostConfig hostName="site2.example.com">
<Certificate certificateFile="conf/site2.example.com.crt" certificateKeyFile="conf/site2.example.com.key" />
</SSLHostConfig>
</Connector>
<!-- If a client doesn't send a Host: header or puts the IP in the Host: header it ends up on site1.example.net -->
<Engine defaultHost="site1.example.net" name="Catalina">
<Host appBase="webapps/site2.example.com" name="site2.example.com">
...
</Host>
<Host appBase="webapps/site1.example.net" name="site1.example.net">
<!-- We need it for the redirect -->
<Valve className="org.apache.catalina.valves.rewrite.RewriteValve" />
</Host>
</Engine>
</Service>
# If the client connected through HTTPS
RewriteCond %{HTTPS} on
# Temporarily redirect to the HTTP version
RewriteRule ^ http://site1.example.net%{REQUEST_PATH} [R,L]
[为了不使用任何注册的域,让我们使用
site1.example.net
和site2.example.com
],它们是为文档目的而保留的。]从 HTTPS 到 HTTP 的重定向与通过 twitch 从 HTTP 到 HTTPS 的重定向一样工作:当客户端打开时
https://site1.example.net
,服务器必须提供受信任的 TLS 证书,site1.example.net
然后才能进行任何重定向。否则将导致浏览器中出现安全警告。我会为此使用 Let's Encrypt 证书。否则你只需要
<Host>
在你的<Engine>
和<Certificate>
你的<Connector>
. 您的site1.example.com
主机需要RewriteValve
执行重定向:为了配置
RewriteValve
你只需要创建一个conf/Catalina/site1.example.net/rewrite.config
包含内容的文件