I have an apache server that lives behind a load balancer/proxy thing, within a k8s pod/container
At my main httpd.conf we have
ServerName my.site.example.com
(I have also tried my.site.example.com:443)
When you connect via https://my.site.example.com you will get to my page -- but the service in the container is actually listening on 8443. So we have
ServerName my.site.example.com # Or my.site.example.com:443, doesn't seem to matter <VirtualHost *:8443> Include redirects.conf </VirtualHost> Within redirects I have something like
RewriteRule ^/foo/bar$ /bang/quux [R=301,L] This kind of works except for apache will return a 301 for my.site.example.com:8443
Naturally that's a problem. After searching the documentation and trying a multitude of different approaches, it wasn't until I did
<VirtualHost *:8443> ServerName my.site.example.com:443 Include redirects.conf </VirtualHost> That it stopped adding :8443. UseCanonicalName and UseCanonicalPhysicalPort seemed to have zero effect without ServerName in the VirtualHost.
Our real config is quite large, so it's entirely possible that we have something else somewhere that is borking this up, but I haven't seen anything (grep -Inr ServerName config/path only returned the one global name, for instance) that leads me to believe that we have anything buggy.
I think that this is just how it's supposed to work but I don't understand based on Apache docs why.
So... am I doing something wrong here, or is it expected that I have to add ServerName to all of my VirtualHost entries?