Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 14 of 14
  1. #1
    Member
    Join Date
    Jan 2008
    Posts
    5

    Default Hooking nginx into cPanel/WHM

    It isn't hard to do the only problem is getting a supported post hook to have new accounts have their own .conf file in the nginx configuration directory and just include every file in there.

  2. #2
    Member
    Join Date
    Mar 2007
    Posts
    35

    Default

    Quote Originally Posted by ralphlw View Post
    It isn't hard to do the only problem is getting a supported post hook to have new accounts have their own .conf file in the nginx configuration directory and just include every file in there.
    maybe the cpanel staff can provide the hook so we can play with it

  3. #3
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,189
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    Quote Originally Posted by ralphlw View Post
    It isn't hard to do the only problem is getting a supported post hook to have new accounts have their own .conf file in the nginx configuration directory and just include every file in there.
    What cPanel/WHM function(s) do you need to hook? There is a possibility we may already offer the ability to do post hooks on the functionality you need to hook.

  4. #4
    Member
    Join Date
    Mar 2007
    Posts
    35

    Default

    Quote Originally Posted by cPanelDavidG View Post
    What cPanel/WHM function(s) do you need to hook? There is a possibility we may already offer the ability to do post hooks on the functionality you need to hook.
    add new account, domain parking, domain addon, domain forwarding

    we need the hook to reload the script to generate new vhost.conf for nginx

  5. #5
    cPanel Partner NOC cPanel Partner NOC Badge nvez's Avatar
    Join Date
    Jul 2006
    Posts
    40

    Default

    Quote Originally Posted by nsetiono View Post
    add new account, domain parking, domain addon, domain forwarding

    we need the hook to reload the script to generate new vhost.conf for nginx
    Let me introduce you to ..

    /scripts/postwwwacct

    That's for after creating a new account.

    For the others, I'm sure cPanel has something in place or you can dig for that yourself.

    If they don't offer it, you could easily have a cronjob that runs every 5 minutes for the others.

  6. #6
    Member
    Join Date
    Mar 2007
    Posts
    35

    Default

    Quote Originally Posted by nvez View Post
    Let me introduce you to ..

    /scripts/postwwwacct

    That's for after creating a new account.

    For the others, I'm sure cPanel has something in place or you can dig for that yourself.

    If they don't offer it, you could easily have a cronjob that runs every 5 minutes for the others.
    what i'm affraid is if there is a trouble if restarting nginx every 5 minutes

  7. #7
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,189
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    Quote Originally Posted by nsetiono View Post
    add new account, domain parking, domain addon, domain forwarding

    we need the hook to reload the script to generate new vhost.conf for nginx
    You can find some more information on /scripts/postwwwacct at:

    ScriptHooks < DevHooks < TWiki

    Domain parking, addon domains and domain forwarding are handled by cPanel API functions. Part of this API architecture is the ability to create function hooks to execute your own shell script after these functions are executed. You can read more about this at:

    Hooking into cPanel Functionality

    We have some documentation on the Addon Domains API functions at: AddonDomainRef < DeveloperResources/ApiRef < TWiki

    We have documentation on Park Domains API functions at:

    ParkRef < DeveloperResources/ApiRef < TWiki

    The API 1 function call for adding a redirect (as used by the cPanel interface) is:

    <cpanel Mime="add_redirect(path, type, url, domain, wildcard, rdwww)">

    Mime is the module name
    add_redirect is the function name

    path is the path within the URL to redirect (if any)

    type is either temp or permanent

    url is the URL to redirect to

    domain is .* if ** All Public Domains ** is selected, otherwise it is the domain/addon domain/etc to redirect.

    wildcard is: 1 if this is a wildcard redirect

    rdwww is: 2 if "Only redirect with www. " is selected, 0 if "Redirect with or without www." is selected, or 1 if "Do Not Redirect www." is selected.

  8. #8
    Member
    Join Date
    Mar 2007
    Posts
    35

    Default

    Quote Originally Posted by cPanelDavidG View Post
    You can find some more information on /scripts/postwwwacct at:

    ScriptHooks < DevHooks < TWiki

    Domain parking, addon domains and domain forwarding are handled by cPanel API functions. Part of this API architecture is the ability to create function hooks to execute your own shell script after these functions are executed. You can read more about this at:

    Hooking into cPanel Functionality

    We have some documentation on the Addon Domains API functions at: AddonDomainRef < DeveloperResources/ApiRef < TWiki

    We have documentation on Park Domains API functions at:

    ParkRef < DeveloperResources/ApiRef < TWiki

    The API 1 function call for adding a redirect (as used by the cPanel interface) is:

    <cpanel Mime="add_redirect(path, type, url, domain, wildcard, rdwww)">

    Mime is the module name
    add_redirect is the function name

    path is the path within the URL to redirect (if any)

    type is either temp or permanent

    url is the URL to redirect to

    domain is .* if ** All Public Domains ** is selected, otherwise it is the domain/addon domain/etc to redirect.

    wildcard is: 1 if this is a wildcard redirect

    rdwww is: 2 if "Only redirect with www. " is selected, 0 if "Redirect with or without www." is selected, or 1 if "Do Not Redirect www." is selected.
    how to adding it so if anyone adding a domain name it will run nginx.sh to regenerate the file vhost.conf

  9. #9
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,189
    cPanel/Enkompass Access Level

    Root Administrator

    Arrow Friendly Moderator Note

    I have moved our discussion about APIs and Hooks to a new thread in the cPanel/WHM Developer Discussions forum, where you are likely to receive more relevant feedback.

  10. #10
    Member
    Join Date
    Mar 2007
    Posts
    35

    Default

    Quote Originally Posted by cPanelDavidG View Post
    I have moved our discussion about APIs and Hooks to a new thread in the cPanel/WHM Developer Discussions forum, where you are likely to receive more relevant feedback.
    So anyone want to share the cpanel hook for reloading vhost.conf file when a user using addon domain, domain parking, etc ?

  11. #11
    Member
    Join Date
    Mar 2007
    Posts
    35

    Default

    currently i know the file responsible for domain addon add and domain addon deleting which is doadddomain.html and dodeldomain.html.

    how i can put a code on it so it will run /scripts/nginx.sh after a domain successful added or deleted ?

    for doadddomain.html, i know it's should be put after the code below

    Code:
    <cpanelif !$CPERROR{'addondomain'}>
       <cpanel print="$FORM{'domain'}"> &nbsp;<cpanel langprint="AODCreateYes">!<br />
      <!--  <cpanel Ftp="addftp($FORM{'user'},$FORM{'pass'},$FORM{'dir'},,,$FORM{'dir'})"> -->
    <!--    If you would like to create an ftp account to upload files to this new domain, you can do so here: <a href="../ftp/addftp.html?domain$
    <br/>   <cpanel langprint="AODGoFileMgr">: <a target="_blank" href="../files/index.html?dir=<cpanel print="$homedir">/<cpanel print="$FORM{'d$
    
    </cpanelif>
    and for dodeldomain.html it's should be put after the code below

    Code:
    <cpanelif !$CPERROR{'addondomain'}>
       <cpanel langprint="AODAddedPre">&nbsp; <cpanel print="$FORM{'domain'}"> &nbsp;<cpanel langprint="RDRedRemText">!
        <br /><cpanel Ftp="delftp($FORM{'domain'})">
    </cpanelif>
    the problem is i don't know what is the syntax to run /scripts/nginx.sh (my nginx generation is nginx.sh)

  12. #12
    cPanel Development cpanelkenneth's Avatar
    Join Date
    Apr 2006
    Posts
    3,788
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    Quote Originally Posted by nsetiono View Post
    currently i know the file responsible for domain addon add and domain addon deleting which is doadddomain.html and dodeldomain.html.
    Modifying the theme files will not accomplish what you want. DavidG earlier linked to our integration documentation. Please read the documents pertaining to 'hook' abilities.
    Kenneth
    Product Manager
    cPanel, Inc.

  13. #13
    Member
    Join Date
    Mar 2007
    Posts
    35

    Default

    Quote Originally Posted by cpanelkenneth View Post
    Modifying the theme files will not accomplish what you want. DavidG earlier linked to our integration documentation. Please read the documents pertaining to 'hook' abilities.
    is there any sample how to use the hook ?

    i really newbie here about cpanel hook and really don't know what i must do and how to use the hook

  14. #14
    cPanel Quality Assurance Analyst cPanelDon's Avatar
    Join Date
    Nov 2008
    Location
    Houston, Texas, U.S.A.
    Posts
    2,555
    cPanel/Enkompass Access Level

    DataCenter Provider

    Lightbulb

    Quote Originally Posted by nsetiono View Post
    is there any sample how to use the hook ?
    i really newbie here about cpanel hook and really don't know what i must do and how to use the hook
    Please carefully review the documentation; this will be the best resource to help learn. If you have specific questions about something feel free to ask; however, if you need assistance creating something I would consider locating and hiring someone to develop the solution for you.

    The following advertising forums might help with locating a company to help:
    Server Management and Server Repair - cPanel Forums

    For details and examples, please thoroughly review the following documentation; the following link that cPanelDavidG provided should help:
    Hooking into cPanel Functionality

    Additional, more specific documentation pages linked from the above:
    WritingFunctionHooks < DevHooks < TWiki
    ScriptHooks < DevHooks < TWiki
    CustomEventHandler < DevHooks < TWiki

Similar Threads & Tags
Similar threads

  1. Replies: 6
    Last Post: 08-19-2011, 03:38 AM
  2. Ever thought about adding nginx or lighttpd to WHM?
    By McPhil in forum cPanel and WHM Discussions
    Replies: 7
    Last Post: 09-01-2009, 12:53 PM
  3. Using Lighttpd or Nginx instead of Apache on WHM
    By students in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 07-18-2009, 02:27 PM
  4. hooking mysql to cpanel
    By bullwinkle in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 09-01-2003, 09:50 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube