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.

/scripts/rebuildhttpdconf generation failed

Discussion in 'General Discussion' started by Miguel G, Nov 8, 2016.

  1. Miguel G

    Miguel G Active Member

    Joined:
    Jun 4, 2015
    Messages:
    42
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Spain
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hi,

    When I run the rebuildhttpdconf I get the following error:


    /scripts/rebuildhttpdconf
    Initial configuration generation failed with the following message:

    The â/usr/sbin/httpdâcommand (process 12526) reported error number 1 when it ended.

    Rebuilding configuration without any local modifications.

    Failed to generate a syntactically correct Apache configuration.
    Bad configuration file located at /etc/apache2/conf/httpd.conf.work.1F5hQbXi
    Error:
    The â/usr/sbin/httpdâcommand (process 12527) reported error number 1 when it ended.

    I´m trying to modify a SSL virtualhost to not to have any DocumentRoot (I removed that entry in the /var/cpanel/userdata/$USERNAME/ entry but I still can see that entry.

    I´m trying to setup a proxypass directive in the SSL VirtualHost so I don´t need any DocumentRoot entry.

    Thanks!
     
  2. cPJacob

    cPJacob cPanel Product Owner
    Staff Member

    Joined:
    May 2, 2014
    Messages:
    599
    Likes Received:
    90
    Trophy Points:
    103
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    Good morning,

    This is an odd one. I'd recommend keeping the DocumentRoot there, but still adding the proxypass directives via the include file. Could you let us know what changes you made that caused the rebuildhttpdconf to fail? Replication steps would be great.

    Thanks Miguel!
     
  3. Miguel G

    Miguel G Active Member

    Joined:
    Jun 4, 2015
    Messages:
    42
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Spain
    cPanel Access Level:
    Root Administrator
    Twitter:
    I tried to reproduce so you can see the steps. I did so removing the SSL VirtualHost and recreating it (by deleting/adding the certs).

    I also have added under /etc/apache/conf.d/userdata/ssl/2_4/$USERNAME/$SITE/ the following:

    Code:
        ProxyPreserveHost On
        ProxyPass / http://127.0.0.1:80/
        RequestHeader set X-Forwarded-Port "443"
        RequestHeader set X-Forwarded-Proto "https"
    
    Still the rebuildhttpdconf script worked, so then, as a final test I removed the entry documentroot in the file under /var/cpanel/userdata/$USERNAME/ and then the rebuildhttpdconf script failed again.

    What I´m trying to achieve is this:

    - I have Varnish in the 80 port caching Wordpress pages hosted by Cpanel, since Varnish doesn´t support SSL, I searched around and most people recommended for this setup using Nginx in proxy mode, passing the request to Varnish and being the frontend for the 443 port. What I don´t like of this solution is the lack of integration with WHM/Cpanel having to manually add certs, etc. None of the free Nginx plugins for Cpanel seem to have SSL support. Besides I´m testing Nginx in a separate machine and I´m having issues with mixed content.

    - Researching for this solution I came across someone that has done the same but using Apache itself here. What I like of this solution is that users could setup their certificates in WHM/Cpanel. I´m trying to make it work and hopefully get a solution that all users could make it work by themselves with some instructions.

    - Of course I´m trying to avoid to have duplicated content with http and https. I haven´t figured out that yet.

    Hope this helps more to understand my setup.
     
  4. Miguel G

    Miguel G Active Member

    Joined:
    Jun 4, 2015
    Messages:
    42
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Spain
    cPanel Access Level:
    Root Administrator
    Twitter:
    Ok, it seems it´s working the proxypass changing 127.0.0.1 to the IP address of the server (Varnish doesn´t seem to like localhost connections).

    Now I have to solve the duplicated content issue since you can both access the website through http and https. Rewrites in .htaccess doesn´t seem to work.
     
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,064
    Likes Received:
    1,287
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    Rather than removing the documentroot entry, try changing it to a value such as "/dev/null" to see if that makes a difference.

    Thank you.
     
  6. Miguel G

    Miguel G Active Member

    Joined:
    Jun 4, 2015
    Messages:
    42
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Spain
    cPanel Access Level:
    Root Administrator
    Twitter:
    I have fixed it adding this to .htaccess

    Code:
    RewriteEngine On
    RewriteCond %{HTTP:X-Forwarded-Proto} !https
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    
    and this in wp-config.php (I´m using Wordpress):

    Code:
    if ( (!empty( $_SERVER['HTTP_X_FORWARDED_HOST'])) ||
         (!empty( $_SERVER['HTTP_X_FORWARDED_FOR'])) ) {
        // http://wordpress.org/support/topic/wordpress-behind-reverse-proxy-1
        $_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
        define('WP_HOME', 'https://www.mysite.com');
        define('WP_SITEURL', 'https://www.mysite.com');
        $_SERVER['HTTPS'] = 'on';
    }
    
    Is there any way I can add automatically in every SSL VirtualHost the ProxyPass entry so I don´t have to do it manually?

    Thanks!
     
  7. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,064
    Likes Received:
    1,287
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
  8. Miguel G

    Miguel G Active Member

    Joined:
    Jun 4, 2015
    Messages:
    42
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Spain
    cPanel Access Level:
    Root Administrator
    Twitter:
    Many thanks! How can I remove the access and transfer logs for all SSL virtualhosts? The cache system I have in the middle is keeping track of the requests and I don´t want to have duplicate entries.
     
  9. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,064
    Likes Received:
    1,287
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Could you verify if this is addressed on the piping varnishncsa logs into stat logs thread?

    Thanks!
     
Loading...

Share This Page