Bug 39928 - port no detected when file name not in URL
Summary: port no detected when file name not in URL
Status: RESOLVED LATER
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_vhost_alias (show other bugs)
Version: 2.2.2
Hardware: PC Linux
: P2 normal with 3 votes (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL: http://apachebug.tdd.org.uk:81
Keywords: MassUpdate
Depends on:
Blocks:
 
Reported: 2006-06-28 23:18 UTC by Robert Bruce
Modified: 2018-11-07 21:09 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Bruce 2006-06-28 23:18:46 UTC
I have apache listening on two ports, 80 and 81. I use port 80 for live
websites, port 81 for test websites.

If the filename is missing for the URL, then the port value is not set and the
default 80 is used.

I am using the following for my mass host rule

VirtualDocumentRoot /home/sites%p/%0/public_html

I have

/home/sites80/apachebug.tdd.org.uk/public_html
/home/sites81/apachebug.tdd.org.uk/public_html

if I visit http://apachebug.tdd.org.uk:81 I get the index.html for
http://apachebug.tdd.org.uk

http://www.tdd.org.uk:81/index.html returns file not found, expected as it
doesn't exit (the directory is actually empty)
Comment 1 Marc Mengel 2008-06-06 15:05:33 UTC
(In reply to comment #0)

We are seeing the same problem, in particular when we should be looking for a DirectoryIndex, it looks in the port 80 server's VirtualDocumentRoot, rather than in the port-numbered server we are coming from.
Comment 2 Marc Mengel 2008-11-07 08:05:17 UTC
Okay, so after much confusion, I have a workaround for this.

First, you have to use Rewrite based mass virtual hosting, and
second you have to set an environmnent variable (i.e. MY_PORT).

So instead of:
  VirtualDocumentRoot /appora/products/web/%0:%p/html
  VirtualScriptAlias  /appora/products/web/%0:%p/cgi-bin

You need:
  RewriteCond %{ENV:MY_PORT} ^$ 
  RewriteRule (.*) $1 [env=MY_PORT:%{SERVER_PORT}]
  RewriteMap lowercase int:tolower
  RewriteCond %{REQUEST_URI} !/cgi-bin/
  RewriteRule ^/(.*)$   /appora/products/web/%{SERVER_NAME}:%{ENV:MY_PORT}/html/$1      
  RewriteCond %{REQUEST_URI} /cgi-bin/
  RewriteRule ^/(.*)$   /appora/products/web/%{SERVER_NAME}:%{ENV:MY_PORT}/$1 [T=application/x-httpd-cgi]

This is the cook book Rewrite based mass virtual hosting, except for the part about setting MY_PORT if it isn't set, and using MY_PORT instead of SERVER_PORT.

Basically, somewhere the SERVER_PORT stuff gets lost when doing things like doing an index.html lookup, but the MY_PORT environment variable doesnt.
Comment 3 William A. Rowe Jr. 2018-11-07 21:09:59 UTC
Please help us to refine our list of open and current defects; this is a mass update of old and inactive Bugzilla reports which reflect user error, already resolved defects, and still-existing defects in httpd.

As repeatedly announced, the Apache HTTP Server Project has discontinued all development and patch review of the 2.2.x series of releases. The final release 2.2.34 was published in July 2017, and no further evaluation of bug reports or security risks will be considered or published for 2.2.x releases. All reports older than 2.4.x have been updated to status RESOLVED/LATER; no further action is expected unless the report still applies to a current version of httpd.

If your report represented a question or confusion about how to use an httpd feature, an unexpected server behavior, problems building or installing httpd, or working with an external component (a third party module, browser etc.) we ask you to start by bringing your question to the User Support and Discussion mailing list, see [https://httpd.apache.org/lists.html#http-users] for details. Include a link to this Bugzilla report for completeness with your question.

If your report was clearly a defect in httpd or a feature request, we ask that you retest using a modern httpd release (2.4.33 or later) released in the past year. If it can be reproduced, please reopen this bug and change the Version field above to the httpd version you have reconfirmed with.

Your help in identifying defects or enhancements still applicable to the current httpd server software release is greatly appreciated.