0

It turns out that locations controlled by ajp ProxyPass on my site are being processed before the VirtualHost redirect, which came to my attention because google has indexed 25k+ pages at ardownload.example.org - a subdomain I have never used and don't know how they started down that path. They also have about 12k pages from other subdomains that "don't exist". I traced the problem to the fact that the redirect is not respected if it hits an ajp proxied location.

The desired result would be that all subdomains are properly redirected to the main site while preserving the url and query string.

Current VirtualHost with partially ignored redirect:

<VirtualHost *:80>
    ServerName example.org
    ServerAlias *.example.org
    RedirectPermanent / https://www.example.org/
</VirtualHost>

Current location proxy causing the error.

<Location /tomcatlocation/>
     ProxyPreserveHost on
     ProxyPass ajp://127.0.0.1:8009/tomcatlocation/ retry=0
     ProxyPassReverse ajp://127.0.0.1:8009/tomcatlocation/
</Location>

something like foo.example.org/tomcatlocation/ or foo.example.org/tomcatlocation will not redirect, while truncating that to foo.example.org/tomcatlocatio will correctly redirect.

I have had no luck searching for information on this. Thanks.

apache2ctl -S:

VirtualHost configuration:
*:80                   is a NameVirtualHost
         default server www.example.org (/etc/apache2/sites-enabled/000-default.conf:1)
         port 80 namevhost www.example.org (/etc/apache2/sites-enabled/000-default.conf:1)
         port 80 namevhost example.org (/etc/apache2/sites-enabled/000-default.conf:10)
                 wild alias *.example.org
         port 80 namevhost example.net (/etc/apache2/sites-enabled/000-default.conf:15)

... other domains truncated ...

*:443                  is a NameVirtualHost
         default server example.org (/etc/apache2/sites-enabled/default-ssl.conf:2)
         port 443 namevhost example.org (/etc/apache2/sites-enabled/default-ssl.conf:2)
                 alias www.example.org
         port 443 namevhost example.net (/etc/apache2/sites-enabled/default-ssl.conf:25)
                 alias www.example.net
         
... other domains truncated ...


ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex default: dir="/var/lock/apache2" mechanism=fcntl 
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
Mutex ssl-cache: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
sgc
  • 1
  • 1

1 Answers1

0

I moved the Location directive to within the :443 VirtualHost that the :80 VirtualHost redirects to, and it works as intended since it is now processed after the redirect.

sgc
  • 1
  • 1