Closed (fixed)
Project:
Domain
Version:
5.x-1.4
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
16 Jun 2008 at 03:42 UTC
Updated:
4 Sep 2009 at 16:29 UTC
Jump to comment: Most recent file
I have drupal running on http://localhost:8080/drupal and this is how domain access is configured
Primary domain name: localhost
Sub-domain: sub.localhost
With this configuration everytime I access http://sub.localhost:8080/drupal, it always fall back to primary domain.
The reason is domain access could not identify it as a valid domain. The problem is in this line
// Cribbed from bootstrap.inc -- removes port protocols from the host value.
$_subdomain = strtolower(implode('.', array_reverse(explode(':', rtrim($_SERVER['HTTP_HOST'], '.')))));
That line doesn't remove port protocol from the host value, it simply take this value sub.localhost:8080 and
transform it to 8080.sub.localhost. Then when DA trying to look for a domain record with that value, surely it
would never find it.
Suggested patch attached.
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | domain_port.patch | 3.13 KB | agentrickard |
| #8 | non_standard_port.patch | 3.84 KB | agentrickard |
| #3 | non-standard_port_1.patch | 3.72 KB | ariflukito |
| #1 | non-standart_port_0.patch | 1.44 KB | ariflukito |
| non-standard_port.patch | 1.17 KB | ariflukito |
Comments
Comment #1
ariflukito commenteddomain_get_uri() still needs to be fixed to include port number
edit: new patch
Comment #2
agentrickardThat line, by the way, is cribbed from Drupal's bootstrap.inc -- settings files can recognize different ports as desired.
Thanks for the patch, a little testing is required to make sure it doesn't break anything -- it shouldn't. You could, of course, register your domains as 8080.example.com.
Similar logic is in the settings includes for Domain Prefix and Domain Conf, so the patch would need to be extended to them.
Comment #3
ariflukito commentedI don't see how registering domains as 8080.example.com would work. The path to the domain will be http://8080.example.com and the webserver is not running on port 80.
edit: new patch testing needed
Comment #4
agentrickardI am also not sure why we need to support non-standard ports.
Comment #5
ariflukito commentedWell for me the reason is to support different environments. My development server is running on port 8080 and port 80 is already used by IIS. I think it is useful for testing.
Comment #6
agentrickardThis has come up before -- the issue is for people who allow both port 80 and 8080 on the server. How do we handle those?
Comment #7
agentrickardPatch is malformed. Please use UNIX formatted linebreaks and patch against HEAD.
http://drupal.org/patch/create
Comment #8
agentrickardThere was also an issue with Windows line breaks in the settings_domain_prefix.inc file.
This patch is actually against DRUPAL-5 not HEAD (HEAD is D6),
Seems to be working.
Comment #9
agentrickardComment #10
agentrickardHere's the issue that I have -- and it needs research and feedback. The RFC for HTTP says that ports are part of the URL, and that port 80 is the default:
http://www.ietf.org/rfc/rfc2616.txt
Based on my quick read of that and of http://www.ietf.org/rfc/rfc3986.txt, I think the proper thing to do is _not_ to strip the port, if it exists, _unless_ it is port 80. I recall being asked by someone else to respect port 8080 as a different URL. We should not transpose the port (like Drupal bootstrap does); we should instead allow it as part of the domain identifier string.
Thus, if passed the url : http://example.com:8080, DA should report that as is -- and you should 'register' that domain string. This opens the possibility that http://example.com and http://example.com:80 are equivalent (as in the specification) but http://example.com:8080 is not.
The other idea that this brings up is an "alias registration" that lets you assign alternative domain strings to a single domain. For example, you might register port 8080 as an alias of example.com.
Comment #11
ariflukito commentedWe strip the port only for internal processing to allow DA to find matching configuration. We don't the strip the URI itself so I don't think the RFC is applied to us. It is web browser job to strip default port from URI. The advantage of not registering port number in DA is, when you moving from one host to another or changing your webserver port you don't need to change any configuration. It will just work.
Isn't that now we have this behavior? Or are you saying if we configure web server to listen on multiple ports instead of multiple web servers, then I think this is not in the specification.
I didn't know that http://ABC.com:/ is valid, what does $_SERVER['HTTP_HOST'] give when we enter this uri?
I believe URI producers and normalizers here are web browsers, so they've already done stripping for us so http://ABC:com:/ will work.
I don't know about alias registration why do you want to have port 8080 as an alias? I cannot think of an example use case.
Comment #12
agentrickardI am saying that people can configure their webservers so that example.com and example.com:8080 are different sites.
With the current logic, domain_init() would render example.com:8080 as 8080.example.com. With your patch, it would render as example.com. We probably just need to leave it alone as example.com:8080.
Currently, we do not account for this behavior.
Comment #13
ariflukito commentedMy question is why would anyone makes those as different sites, doesn't seem logical to me.
Comment #14
agentrickardWell, that's the standard. Here's an example.
For a while, I was running Ruby on Rails on LightPPD on my development machine. By default, Apache ran on localhost:80 and LightPPD ran on localhost:3000.
When you start talking about supporting non-standard configurations, you have to account for configurations that you might not use.
Now, I think that Drupal and DA already support non-standard ports. You just have to 'register' them differently.
If you look at the instructions for settings.php -- which DA copies -- you register port 8080 as 8080.example.com:
Under this logic, DA already supports non-standard ports. If this doesn't work, then I might consider a patch. But I am hesitant to make changes to fix what might not be broken.
Comment #15
ariflukito commentedThe setting in Drupal works but not in DA because DA uses the registered domain for the uri.
Ok let's reverse for example you have drupal running on LightPPD on port 3000 and you have something else running on Apache port 80. So drupal can be accessed from this uri http://example.com:3000. You put settings.php in sites/3000.example.com as per documentation. So far everything works.
Now DA, you register one affiliate site1.example.com and these are the different ways you can register it:
- 3000.site1.example.com (as settings.php)
- site1.example.com
- site1.example.com:3000
Now you try to access it through http://site1.example.com:3000. DA will look for 3000.site1.example.com.
First case, match found but the $_domain['path'] will be http://3000.site1.example.com. DA tries to redirect to that uri (drupal_goto($_domain['path']), there is where it fails.
Second and third case, match not found. DA will redirect to primary domain.
Without the patch none of them will work, with my patch the second case will work.
Comment #16
agentrickardYes. I agree. I'm wondering if we should separate the port the way we separate the scheme -- probably not.
Comment #17
agentrickardTesting.
Comment #18
agentrickardOK. I tested this by enabling the following apache ports: 80, 8080, 3000. And it seems to work fine.
You now register the port as part of the domain:
example.com
example.com:8080
example.com:3000
Are all valid.
Comment #19
ariflukito commentedThis patch for D6?
edit: nvm I checked out wrong branch
It works for me
Comment #20
agentrickardThe patch for D6 will be very very similar.
Comment #21
agentrickardCommitted to HEAD and 5-dev.
Thanks!
Comment #22
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #23
kenorb commentedSomething similar: #568508: Domain Access doesn't work with non-standard port (6.x)