Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

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.

SOLVED Editing IfModule mod_include.c on virtualhost permanently

Discussion in 'EasyApache' started by SpaceCowboy, Feb 5, 2017.

  1. SpaceCowboy

    SpaceCowboy Well-Known Member

    Joined:
    Jan 18, 2014
    Messages:
    54
    Likes Received:
    4
    Trophy Points:
    8
    cPanel Access Level:
    Website Owner
    I'm trying to add: Include /etc/apache2/custom.d/globalblacklist.conf
    Inside httpd.conf

    Code:
    <IfModule mod_include.c>
        <Directory "/home/cowboy/public_html">
          SSILegacyExprParser On
         Include /etc/apache2/custom.d/globalblacklist.conf
        </Directory>
      </IfModule>
    This is impossible to do.
    After rebuilding the file. The include gets deleted.
    If i put the the file here: /etc/apache2/conf.d/userdata/ssl/2_4/cowboy/cowboy.org/globalblacklist.conf

    it won't even rebuild because the include happens in the wrong place (right before closing virtualhost).

    So please, how to achieve the change showed on the code section and make it permanently after rebuild?
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,425
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
  3. SpaceCowboy

    SpaceCowboy Well-Known Member

    Joined:
    Jan 18, 2014
    Messages:
    54
    Likes Received:
    4
    Trophy Points:
    8
    cPanel Access Level:
    Website Owner
    Hi i understand that but those directories add the code right before closing </VirtualHost> and i need to add my code inside <IfModule mod_include.c></IfModule>

    See include below:
    Code:
    <IfModule mod_include.c>
       <Directory "/home/cowboy/public_html">
         SSILegacyExprParser On
        Include /etc/apache2/custom.d/globalblacklist.conf <---LINE I NEED TO ADD HERE
       </Directory>
      </IfModule>
    
    ...
    ..
    .
    ..
    
    <--- IT'S ADDING IT HERE INSTEAD
    </VirtualHost>
    
    
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,425
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    An include file's contents will override any value that exists in the primary configuration file, so you should be able to enter a full IfModule section in $includename.conf:

    Code:
      <IfModule include_module>
        <Directory "/home/cpexample01/public_html">
          SSILegacyExprParser On
         Include /etc/apache2/custom.d/globalblacklist.conf
        </Directory>
      </IfModule>
    Thank you.
     
  5. SpaceCowboy

    SpaceCowboy Well-Known Member

    Joined:
    Jan 18, 2014
    Messages:
    54
    Likes Received:
    4
    Trophy Points:
    8
    cPanel Access Level:
    Website Owner
    Just tried it doesn't work.

    Created a file named include-globalblacklist.conf that contains:

    Code:
    <IfModule mod_include.c>
       <Directory "/home/cowboy/public_html">
        SSILegacyExprParser On
       Include /etc/apache2/custom.d/globalblacklist.conf
       </Directory>
      </IfModule>
    
    /etc/apache2/conf.d/userdata/ssl/2_4/*username*/*domain*/include-globalblacklist.conf

    Did /scripts/rebuildhttpdconf
    Built /etc/apache2/conf/httpd.conf OK

    Then check new httpd.conf find the line:
    Code:
    <IfModule mod_include.c>
       <Directory "/home/cowboy/public_html">
        SSILegacyExprParser On
        </Directory>
      </IfModule>
    
    Missing the include.
     
    #5 SpaceCowboy, Feb 10, 2017
    Last edited: Feb 10, 2017
  6. SpaceCowboy

    SpaceCowboy Well-Known Member

    Joined:
    Jan 18, 2014
    Messages:
    54
    Likes Received:
    4
    Trophy Points:
    8
    cPanel Access Level:
    Website Owner
    Please test this. It's not working properly for me.
     
  7. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,425
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    You aren't going to see the actual Include line in the httpd.conf file. It's utilized based on the existence of the following line:

    Code:
    Include "/etc/apache2/conf.d/userdata/ssl/2_4/$username/$domain/*.conf
    Could you let us know the contents of the /etc/apache2/custom.d/globalblacklist.conf file, and the specific method you are using to test it on the website after making the change?

    Thank you.
     
  8. SpaceCowboy

    SpaceCowboy Well-Known Member

    Joined:
    Jan 18, 2014
    Messages:
    54
    Likes Received:
    4
    Trophy Points:
    8
    cPanel Access Level:
    Website Owner
    Hi this is the file:
    github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/blob/master/conf.d/globalblacklist.conf

    I cannot put it on
    Code:
    Include "/etc/apache2/conf.d/userdata/ssl/2_4/$username/$domain/*.conf
    Because it will break apache. That include adds the file before closing virtual host and i need it to be included here:

    Code:
    <IfModule mod_include.c>
       <Directory "/home/cowboy/public_html">
        SSILegacyExprParser On
       Include /etc/apache2/custom.d/globalblacklist.conf <---LINE I NEED TO ADD HERE
       </Directory>
      </IfModule>
     
    #8 SpaceCowboy, Feb 17, 2017
    Last edited by a moderator: Feb 17, 2017
  9. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,425
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    You can modify the default Virtual Host template using the following steps:

    1. Copy the Apache 2.4 default vhost template for to allow for customization:

    Code:
    cp -a /var/cpanel/templates/apache2_4/vhost.default /var/cpanel/templates/apache2_4/vhost.local
    2. Edit /var/cpanel/templates/apache2_4/vhost.local using the editor of your preference (e.g. vi, nano) to change the entries to match your preferences. For example, you can change this entry:

    Code:
      <IfModule include_module>
        <Directory "[% vhost.documentroot %]">
          SSILegacyExprParser On
        </Directory>
      </IfModule>
    With:

    Code:
      <IfModule include_module>
        <Directory "[% vhost.documentroot %]">
          SSILegacyExprParser On
    [% IF vhost.servername == 'yourdomain.tld' -%]
     Include /etc/apache2/custom.d/globalblacklist.conf
    [% ELSE -%]
    #      Include /etc/apache2/custom.d/globalblacklist.conf
    [% END -%]
        </Directory>
      </IfModule>
    Ensure to replace "yourdomain.tld" with the domain name you want the change to apply to.

    3. Save the changes to the file, and then run:

    Code:
    /scripts/rebuildhttpdconf
    Note: You will need to complete the same steps for /var/cpanel/templates/apache2_4/ssl_vhost.default if you want to make the changes for the default SSL Virtual Host template.

    Let us know if this helps.

    Thank you.
     
    egifford_corexcel likes this.
  10. SpaceCowboy

    SpaceCowboy Well-Known Member

    Joined:
    Jan 18, 2014
    Messages:
    54
    Likes Received:
    4
    Trophy Points:
    8
    cPanel Access Level:
    Website Owner
    Thanks this worked, solved!
     
    Infopro likes this.
Loading...

Share This Page