This might actually not be possible, but trying anyway: I want to create a container image for Apache without the need to run as root. So I set up the VirtualHost to listen to port 8080 instead of anything <1024. There's a proxy before Apache which directs the traffic for port 80 to port 8080 on the container. However, when I make Apache redirect, it always adds the port to the Location header. So the redirect send back is "Location: http://mysite:8080/index", which will fail as there's nothing listening on port 8080 publicly.
Is there any way of telling Apache to never add the port number to these redirects? I tried fiddling with UseCanonicalPhysicalPort, but that does not seem to have the desired effect. Is there any way to prevent it from ever adding that port number to anything?
EDIT
Ok, looks like this behaviour is hardcoded, when I look at the source code of mod_rewrite I notice it calls "ap_is_default_port" to determine whether it should add the port in the answer or not. And the only way to override it would be by overriding this line in the source, I think. If anyone knows of a better answer, I'm all ears.