/scripts/rebuildhttpdconf generation failed

Miguel G

Well-Known Member
Jun 4, 2015
86
0
6
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!
 

JacobPerkins

Well-Known Member
May 2, 2014
617
97
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!
 

Miguel G

Well-Known Member
Jun 4, 2015
86
0
6
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.
 

Miguel G

Well-Known Member
Jun 4, 2015
86
0
6
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.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,267
463
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.
 

Miguel G

Well-Known Member
Jun 4, 2015
86
0
6
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!
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,267
463

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,267
463