The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

mod_userdir or Not?

Discussion in 'General Discussion' started by markb14391, Dec 12, 2011.

  1. markb14391

    markb14391 Well-Known Member

    Joined:
    Jun 9, 2008
    Messages:
    305
    Likes Received:
    2
    Trophy Points:
    18
    Hi,

    We run with mod_userdir to prevent bandwidth stealing.

    However, new users want to access their website immediately, even while waiting for the domain to propagate.

    Is there a solution? Is there a way to allow this without just turning mod_userdir completely off?

    Thanks and best regards,

    Mark
     
  2. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Hello Mark,

    Actually, if you were using mod_userdir, then it would allow the temporary url, so you would mean you have mod_userdir disabled (you have enabled the tweak to disallow it).

    There are two available options if you are going to disallow using mod_userdir for sites:

    1) On account or domain creation, email the account user to mention using the hosts file to temporarily set the domain to point to the machine to see it:

    Hosts (file) - Wikipedia, the free encyclopedia

    2) Create a subdomain of the server's main domain for every new account such as subdomain1.myserver.com, subdomain2.myserver.com

    Creating a subdomain could be done using a script in /scripts/postwwwacct hook that will create such a subdomain for you. Since you would already control the main domain on the machine (the one you have associated with the server's hostname), you could add subdomains onto it and have those work. The subdomain would then be usable until they change their domain to point to the machine.

    To see details on postwwwacct hook script, please review ScriptHooks < AllDocumentation < TWiki

    Thanks!
     
  3. markb14391

    markb14391 Well-Known Member

    Joined:
    Jun 9, 2008
    Messages:
    305
    Likes Received:
    2
    Trophy Points:
    18
    Yep, that's what I meant.

    Good idea, but I think it would be over some users' heads.

    Sounds like a plan. I've not had much luck with postwwwacct syntax. Can you (or anyone) point me to some snippets of code that might help?

    Thanks!
     
  4. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    You might want to head over to our developers area to ask this question:

    cPanel Developers
     
  5. markb14391

    markb14391 Well-Known Member

    Joined:
    Jun 9, 2008
    Messages:
    305
    Likes Received:
    2
    Trophy Points:
    18
    I've been looking at the subdomain idea (not just automating it, but trying to set it up manually to test first). I'm not sure I grasp how to do it.

    The suggestion is to create a subdomain under the main domain.

    So, if user creates cPanel account for userdomain.com, we would create a subdomain, e.g., userdomain.maindomain.com, under which they would access their site without mod_userdir.

    My question is how we create that subdomain...what kind of record, and where does it point? If the user doesn't have a static IP, we can't just create an A record. If we do a CNAME pointing to the user's domain, that's a problem because the whole issue here is waiting for the domain to propagate.

    Any ideas?

    Thanks,

    Mark
     
  6. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Yes, maindomain.com represents the main domain of the server itself, the one that is being used by the hostname. Typically, you have server.mymaindomain.com on a machine and mymaindomain.com is under your control. You'd have that main domain using DNS on your server. Since you control it, you can create subdomains on it for these accounts for users to have working as a placement until their actual domain propagates to your server. The suggestion isn't to add a subdomain on the user's domain, but a subdomain on your server's main domain.
     
  7. markb14391

    markb14391 Well-Known Member

    Joined:
    Jun 9, 2008
    Messages:
    305
    Likes Received:
    2
    Trophy Points:
    18
    Thanks. I understand the gist...we'd create a subdomain under our main domain (that's under our control), and that would point to the customer's site so they could access their site during propagation.

    Two followup questions:

    1) What method do you recommend to point that subdomain to the new client site? I don't think an A record would work unless the client has a static IP, right? (And, due to IP allocation issues, few of our clients' sites will have static IPs.) I mean, if we just point it at the main shared IP, that server wouldn't necessarily know how to route the traffic to that site. Or would it be a CNAME or another method?

    2) How could we automate this creation? I know it would be a postwwwacct situation, but I've never seen enough of an explanation of the syntax to know how we might set up the directive to do this. Any help (pointing in the right direction) will be appreciated.

    Thanks,

    Mark
     
  8. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    All shared sites under the shared IP route using httpd.conf to determine which host is served. You would use the A record IP of the shared IP for that account if they are on the shared IP. You can test it out yourself to see the results. Create a new account in WHM > Create a New Account using a subdomain off your main domain. The site will route to the new location because httpd.conf will be able to know when you hit that subdomain it should go to /home/username/public_html spot for that subdomain.

    As for automation, I already suggested posting in the developers area earlier. This is a developer question. Please post it there:

    cPanel Developers
     
  9. markb14391

    markb14391 Well-Known Member

    Joined:
    Jun 9, 2008
    Messages:
    305
    Likes Received:
    2
    Trophy Points:
    18
    Hi,

    Okay, it's getting clearer now but I'm still confused about a little of the process:

    So the new account would be created as a subdomain (off the main domain), not a domain? If so, that eliminates the need to do the post subdomain creation, if it's done during the account creation.

    The questions:

    - How can we have cPanel set up a new account as a subdomain? (These will be automated signups via WHMCS.)
    - What if the user is registering a domain, or pointing a domain to their site? How do we accommodate that, in a way that doesn't complicate things for the user?

    Thanks,

    Mark
     
  10. markb14391

    markb14391 Well-Known Member

    Joined:
    Jun 9, 2008
    Messages:
    305
    Likes Received:
    2
    Trophy Points:
    18
    One other questionL

    How will this be done with multiple servers? For example, we have:

    host1.ourdomain.com
    host2.ourdomain.com
    host3.ourdomain.com

    ...etc.

    So, if a new client is created on host2 (for example), I'm not sure how this would all be handled correctly. Or will it kind of happen automatically, because the subdomain will be assigned to a certain subdirectory on the IP address of host2?

    I hope I've explained what I'm wondering about.
     
    #10 markb14391, Feb 6, 2012
    Last edited: Feb 6, 2012
  11. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Hi Mark,

    Please do post these into the developer's area, since I wouldn't know how to automate using the API for what you are asking:

    For the user signing up, you could have them sign up using their domain and either place that domain as a parked domain on the account or have it the primary domain and the subdomain as a parked domain. A parked domain would point to the same document root. Your automation tools will need to account for the process, and that's where using the API would come into play.

    For the second questions on using the same main domain on multiple machines, the A record IP will determine which machine has the subdomain off the main domain. Think of it this way, host1.ourdomain.com is pointed to a specific machine using the IP address for the A record. The hostname is simply a subdomain off ourdomain.com, which is exactly the same as what you'd be doing for these user subdomains. You can put them onto any machine in the cluster of servers so long as the A record is pointing to the correct machine where the site will belong.

    Hope that clarifies things for you.

    Thanks!
     
  12. ruzbehraja

    ruzbehraja Well-Known Member

    Joined:
    May 19, 2011
    Messages:
    383
    Likes Received:
    7
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    I guess you may have seen this, but incase you haven't, then FYI you can allow only the new user to access his site through the temporary url.

    Apache mod_userdir Tweak

    Wouldn't this be easier?

    Hope this is what you meant.
     
Loading...

Share This Page