configuration for domain other than localhost

150 views
Skip to first unread message

Leho Kraav

unread,
Dec 18, 2009, 4:55:29 AM12/18/09
to EtherPad Open Source Discussion
hi

maybe a a few lines on the subj? getting past 'invalid superdomain' is
the problem.

Aaron Iba

unread,
Dec 18, 2009, 5:05:14 AM12/18/09
to etherpad-open-...@googlegroups.com
I think you'll want to add the domain you would like to use to the list of "superdomains" in globals.js.


I think it only works with two-part domains, of the form x.y, because it assumes that any request for x.y.z should be routed to the "professional domain" x.  The logic around this behavior is contained in pro_utils.js:


If you want to just allow all domains to serve the "regular" etherpad site, then you could probably change isProDomainRequest() to always return true.  Note that there are two versions of this function, one in utils.js and one in pro_utils.js:


Hope this helps.

Aaron

Andrew Fong

unread,
Dec 19, 2009, 2:55:28 AM12/19/09
to EtherPad Open Source Discussion
I got x.y.z domains working just be editing globals.js.

I'd recommend just trying that first before editing pro_utils.js.
Making isProDomainRequest() return gave me errors about being unable
to find the id for a subdomain record.

-- Andrew

On Dec 18, 2:05 am, Aaron Iba <a...@aaroniba.net> wrote:
> I think you'll want to add the domain you would like to use to the list of
> "superdomains" in globals.js.
>

> http://code.google.com/p/etherpad/source/browse/trunk/etherpad/src/et...


>
> I think it only works with two-part domains, of the form x.y, because it
> assumes that any request for x.y.z should be routed to the "professional
> domain" x.  The logic around this behavior is contained in pro_utils.js:
>

> http://code.google.com/p/etherpad/source/browse/trunk/etherpad/src/et...


>
> If you want to just allow all domains to serve the "regular" etherpad site,
> then you could probably change isProDomainRequest() to always return true.
>  Note that there are two versions of this function, one in utils.js and one
> in pro_utils.js:
>

> http://code.google.com/p/etherpad/source/browse/trunk/etherpad/src/et...http://code.google.com/p/etherpad/source/browse/trunk/etherpad/src/et...

John McLear

unread,
Dec 21, 2009, 3:54:17 PM12/21/09
to EtherPad Open Source Discussion
I had to edit src/main.js replacing etherpad.com with with domain.
That didn't fix the issue that I want to have pro domains so users can
password secure.

My domains etc. are working fine, site is at http://primarypad.com -
tried http://monkey.primarypad.com and got no where..

Anyone any idea?

Cheers


On Dec 18, 10:05 am, Aaron Iba <a...@aaroniba.net> wrote:
> I think you'll want to add the domain you would like to use to the list of
> "superdomains" in globals.js.
>

> http://code.google.com/p/etherpad/source/browse/trunk/etherpad/src/et...


>
> I think it only works with two-part domains, of the form x.y, because it
> assumes that any request for x.y.z should be routed to the "professional
> domain" x.  The logic around this behavior is contained in pro_utils.js:
>

> http://code.google.com/p/etherpad/source/browse/trunk/etherpad/src/et...


>
> If you want to just allow all domains to serve the "regular" etherpad site,
> then you could probably change isProDomainRequest() to always return true.
>  Note that there are two versions of this function, one in utils.js and one
> in pro_utils.js:
>

> http://code.google.com/p/etherpad/source/browse/trunk/etherpad/src/et...http://code.google.com/p/etherpad/source/browse/trunk/etherpad/src/et...

John McLear

unread,
Dec 21, 2009, 4:20:52 PM12/21/09
to EtherPad Open Source Discussion
I totally forgot I had to register first.. My bad.. working now :)

On Dec 21, 8:54 pm, John McLear <johnym...@gmail.com> wrote:
> I had to edit src/main.js replacing etherpad.com with with domain.
> That didn't fix the issue that I want to have pro domains so users can
> password secure.
>
> My domains etc. are working fine, site is athttp://primarypad.com-

> triedhttp://monkey.primarypad.comand got no where..


>
> Anyone any idea?
>
> Cheers
>
> On Dec 18, 10:05 am, Aaron Iba <a...@aaroniba.net> wrote:
>
>
>
> > I think you'll want to add the domain you would like to use to the list of
> > "superdomains" in globals.js.
>
> >http://code.google.com/p/etherpad/source/browse/trunk/etherpad/src/et...
>
> > I think it only works with two-part domains, of the form x.y, because it
> > assumes that any request for x.y.z should be routed to the "professional
> > domain" x.  The logic around this behavior is contained in pro_utils.js:
>
> >http://code.google.com/p/etherpad/source/browse/trunk/etherpad/src/et...
>
> > If you want to just allow all domains to serve the "regular" etherpad site,
> > then you could probably change isProDomainRequest() to always return true.
> >  Note that there are two versions of this function, one in utils.js and one
> > in pro_utils.js:
>

> >http://code.google.com/p/etherpad/source/browse/trunk/etherpad/src/et......

Paul Archer

unread,
Dec 30, 2009, 9:33:02 AM12/30/09
to EtherPad Open Source Discussion
OK, figured it out:

The function getRequestSuperdomain (in pro/pro_utils.js) only grabs
the top two levels of the domain:

function getRequestSuperdomain() {
var parts = request.domain.split('.');
parts.reverse();
if (parts[0] == ".") {
parts.shift();
}
return [parts[1], parts[0]].join('.'); // two levels only
}

So it will take a domain like test1.etherpad.example.com and strip it
down to just example.com, which it returns. Then the function
isProDomainRequest checks to see if that's a valid superdomain.

There's two ways to fix this:

1) Change the function:

function getRequestSuperdomain() {
var parts = request.domain.split('.');
if (parts[0] == ".") {
parts.shift();
}
parts.shift();
return parts.join('.');
}

1) Simply add the two-level domain to your list of superdomains in
globals.js:

var SUPERDOMAINS = {
'etherpad.example.com': true,
'example.com': true
};

Paul Archer

Paul Archer

unread,
Dec 30, 2009, 3:29:38 PM12/30/09
to EtherPad Open Source Discussion
> function getRequestSuperdomain() {
>   var parts = request.domain.split('.');
>   if (parts[0] == ".") {
>     parts.shift();
>   }
>   parts.shift();
>   return parts.join('.');
>
> }

I found out this breaks a couple of things, so I changed it to >


function getRequestSuperdomain() {
var parts = request.domain.split('.');
if (parts[0] == ".") {
parts.shift();
}

if(parts[0] != 'etherpad'){


parts.shift();
}
return parts.join('.');
}


This assumes that the subdomain for your site is 'etherpad'. It's a
bit kludgy, but it helps.

mijo

unread,
Dec 30, 2009, 4:34:41 PM12/30/09
to EtherPad Open Source Discussion
Hi Paul,

I tested your solution and it breaks my installation :-( I changed
the function as follows:

function getRequestSuperdomain() {
var parts = request.domain.split('.');

parts.reverse();


if (parts[0] == ".") {
parts.shift();
}

return [parts[2],parts[1], parts[0]].join('.');
}

Not so elegant, but it works for me :-)

Regards

Michael

Paul Archer schrieb:

Paul Archer

unread,
Dec 30, 2009, 4:44:18 PM12/30/09
to EtherPad Open Source Discussion
> I tested your solution and it breaks my installation :-(  I changed
> the function as follows:
>
> function getRequestSuperdomain() {
>   var parts = request.domain.split('.');
>   parts.reverse();
>   if (parts[0] == ".") {
>     parts.shift();
>   }
>   return [parts[2],parts[1], parts[0]].join('.');
>

I think this is the fundamental problem with this code, at least in
this respect: there's too much assumption about what the domain is
supposed to look like.

Out of curiousity, what is your domain name? I'm using
etherpad.example.com ('example' being a substitute for my work
domain).

Paul

mijo

unread,
Dec 30, 2009, 5:02:19 PM12/30/09
to EtherPad Open Source Discussion
I used the same naming schema like you: http://etherpad.netluchs.de/
and *.etherpad.netluchs.de for the pro-Domains.

Concerning the code I thing the same: there are many hidden
dependencies, assumptions and duplications. This seems to be caused by
the three different versions of etherpad mixed up in one project
(free, pro and pne). Out of experience I know, how such a mess starts
to grow - but until now I always managed to keep this code "in
house" :-)

After setting up a working version of etherpad, the next question I'm
interested in is, how are we (?) going to organize the further
development. We are getting many different forks by now. But this
should be an other topic for next year.

Michael


Paul Archer schrieb:

Marcel Waldvogel

unread,
Jan 7, 2010, 5:08:03 PM1/7/10
to EtherPad Open Source Discussion
Here is a better way of identifying superdomains. The idea is that it
actually identifies the entry in SUPERDOMAINS which is the suffix of
the specified virtual host, no need to search for keywords or use a
constant number of domain levels. There is some duplicated code now in
pro_utils.js, so it could be cleaned up more… (getRequestSuperdomainOLD
() is no longer in use, just for educational purposes)

-Marcel

Index: etherpad/src/etherpad/pro/pro_utils.js
===================================================================
--- etherpad/src/etherpad/pro/pro_utils.js (Revision 5)
+++ etherpad/src/etherpad/pro/pro_utils.js (Revision 6)
@@ -44,7 +44,7 @@
return d.split('.')[0];
}

-function getRequestSuperdomain() {
+function getRequestSuperdomainOLD() {


var parts = request.domain.split('.');
parts.reverse();
if (parts[0] == ".") {

@@ -53,6 +53,18 @@


return [parts[1], parts[0]].join('.');
}

+function getRequestSuperdomain() {
+ var parts = request.domain.split('.');
+ parts.pop(); // Remove one level
+ while (parts.length > 0) {
+ var domain = parts.join('.');
+ if (SUPERDOMAINS[domain]) {
+ return domain;
+ }
+ parts.pop(); // Remove next level
+ }
+}
+
function isProDomainRequest() {
// the result of this function never changes within the same
request.
var c = appjet.requestCache;

Reply all
Reply to author
Forward
0 new messages