Help with redirects and port-forwarding.

Hi,

I'm using Apache/1.3.36 and I don't have any room to change the
version at the moment. I have a separate Virtual Host listening on
port 8001:-

<VirtualHost *:8001>
DocumentRoot "/opt/apache_1.3.36/htdocs"
ServerName www.example.co.uk
ErrorLog /var/log/http/example_error_log
TransferLog /var/log/http/example_access_log

RewriteCond %{REQUEST_URI} !^/portal.*
RewriteCond %{REQUEST_URI} !^/static.*
RewriteCond %{REQUEST_URI} !^/graphics.*
RewriteCond %{REQUEST_URI} !^/css.*
RewriteCond %{REQUEST_URI} !^/cgi-bin/.*
RewriteCond %{REQUEST_URI} !^/favicon.ico
RewriteCond %{REQUEST_URI} !^/robots.txt
RewriteRule ^(.*)$ /portal [R=301]
</VirtualHost>

There is a firewall which is port-forwarding from port 80 to port 8001
on the web servers. The problem is that Apache is constructing
self-referential URLs with the 8001 port number. For example, it's
redirecting from http://www.example.co.uk to
http://www.example.co.uk:8001/portal which is not what I want, I want
it to keep port 80. I have tried using 'UseCanonicalName off' inside
my Virtual Host block to no avail (UseCanonicalName is turned on in
the main host block).

Are there any other suggestions other than writing explicit redirects?
Would UseCanonicalPhysicalPort fix my issue if I were using a later
version?

Cheers,
Phil.

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd.apache.org
" from the digest: users-digest-unsubscribe [at] httpd.apache.org
For additional commands, e-mail: users-help [at] httpd.apache.org
Philip Wigg [ Mi, 16 Dezember 2009 11:38 ] [ ID #2026105 ]

Re: Help with redirects and port-forwarding.

Philip Wigg wrote:
> Hi,
>
> I'm using Apache/1.3.36 and I don't have any room to change the
> version at the moment. I have a separate Virtual Host listening on
> port 8001:-
>
> <VirtualHost *:8001>
> DocumentRoot "/opt/apache_1.3.36/htdocs"
> ServerName www.example.co.uk
> ErrorLog /var/log/http/example_error_log
> TransferLog /var/log/http/example_access_log
>
> RewriteCond %{REQUEST_URI} !^/portal.*
> RewriteCond %{REQUEST_URI} !^/static.*
> RewriteCond %{REQUEST_URI} !^/graphics.*
> RewriteCond %{REQUEST_URI} !^/css.*
> RewriteCond %{REQUEST_URI} !^/cgi-bin/.*
> RewriteCond %{REQUEST_URI} !^/favicon.ico
> RewriteCond %{REQUEST_URI} !^/robots.txt
> RewriteRule ^(.*)$ /portal [R=301]
> </VirtualHost>
>
> There is a firewall which is port-forwarding from port 80 to port 8001
> on the web servers. The problem is that Apache is constructing
> self-referential URLs with the 8001 port number. For example, it's
> redirecting from http://www.example.co.uk to
> http://www.example.co.uk:8001/portal which is not what I want, I want
> it to keep port 80. I have tried using 'UseCanonicalName off' inside
> my Virtual Host block to no avail (UseCanonicalName is turned on in
> the main host block).
>
> Are there any other suggestions other than writing explicit redirects?
> Would UseCanonicalPhysicalPort fix my issue if I were using a later
> version?
>
What happens if you just replace you last RewriteRule by
RewriteRule ^(.*)$ http://www.example.co.uk/portal [R=301]

By doing the [R=301], you are forcing a 301 response back to the browser
anyway, so you might as well make it explicit, and it should not add any
extra overhead.

Otherwise, the easiest solution would be to have your firewall forward
to port 80, not 8001, and change your VirtualHost to use 80.
(And maybe add another listening IP address to your server, if you need
that to distinguish with another existing Apache instance on port 80).

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd.apache.org
" from the digest: users-digest-unsubscribe [at] httpd.apache.org
For additional commands, e-mail: users-help [at] httpd.apache.org
aw [ Mi, 16 Dezember 2009 13:01 ] [ ID #2026106 ]

Re: Help with redirects and port-forwarding.

> What happens if you just replace you last RewriteRule by
> =A0 =A0 RewriteRule ^(.*)$ http://www.example.co.uk/portal [R=3D301]
>
> By doing the [R=3D301], you are forcing a 301 response back to the browse=
r
> anyway, so you might as well make it explicit, and it should not add any
> extra overhead.
>
> Otherwise, the easiest solution would be to have your firewall forward to
> port 80, not 8001, and change your VirtualHost to use 80.
> (And maybe add another listening IP address to your server, if you need t=
hat
> to distinguish with another existing Apache instance on port 80).

Thanks very much for your help. I think I'll just do as you suggest
and redirect explicitly. The rest of the infrastructure is outside of
my control but I think I'll suggest they change it.

Cheers,
Phil.

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd.apache.org
" from the digest: users-digest-unsubscribe [at] httpd.apache.org
For additional commands, e-mail: users-help [at] httpd.apache.org
Philip Wigg [ Mi, 16 Dezember 2009 13:07 ] [ ID #2026108 ]
Webserver » gmane.comp.apache.user » Help with redirects and port-forwarding.

Vorheriges Thema: rewriterules
Nächstes Thema: Questions about implementing SSL/VirtualHosts