Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

For long time I am using Apache instalation which doing automated redirect with mod_rewrite (mainly root redirected to specific app and from HTTP to HTTPS but also other). There are could be severeal domain names (so utilised ServerAlias and UseCanonicalName off) Also there used connection to Tomcat with mod_jk.

There are NO reverse proxy or loadbalance in front of this Apache instance.

In short essential part of config looks like this:

ServerName host1.com
ServerAlias host2.com
UseCanonicalName off
RewriteEngine On
RewriteRule ^/$ "/app1" [R,L]
JkMount /app1/   tomcatAJP
JkMount /app1/*   tomcatAJP

During server upgrade from Apache 2.2.16-6+squeeze11 to 2.2.22-13 we catched two strange issue: 1. mod_jk set through packets not physical port to which comes connection but ServerPort as was figured out by Apache (checked with tcpdump - inside AJP packet said Port:80) 2. redirect performed diferently (diferent schema and/or diferent port)

First issue we have resolved with setting

UseCanonicalPhysicalPort on

see http://httpd.apache.org/docs/2.2/mod/core.html#usecanonicalphysicalport mod_jk start to set correct port inside AJP packet (checked with tcpdump)

Same time second issue become worst. If we connect to HTTPS - It start to add current port (which is 443 for HTTPS) to composed URL. That does seams does not happens if we connect to HTTP

Before migration we had such response:

curl -vk https://host1.com
Location: https://host1.com/app1
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="https://host1.com/app1">here</a>.</p>
<hr>
<address>Apache/2.2.16 (Debian) DAV/2 mod_jk/1.2.30 mod_ssl/2.2.16 OpenSSL/0.9.8o mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1 Server at host1.com Port 443</address>
</body></html>

After migration

curl -vk https://host2.com
Location: http://host2.com/app1
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="http://host2.com/ci_live">here</a>.</p>
<hr>
<address>Apache/2.2.22 (Debian) Server at host2.com Port 80</address>
</body></html>

If we set UseCanonicalPhysicalPort on

curl -vk https://host2.com
Location: http://host2.com:443/app1
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="http://host2.com:443/app1">here</a>.</p>
<hr>
<address>Apache/2.2.22 (Debian) Server at host2.com Port 443</address>
</body></html>

It looks like behavior of mod_jk and mod_rewrite is bug:

  • why mod_jk set ServerPort in AJP while it must be real/physical connection port?

  • why mod_rewrite not able to detect schema (https or http)?

So my question is how to resolve both issues?

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.