clean and correct Apache config template for a cPanel server using EasyApache + NGINX Manager where NGINX handles ports

Apache Config Snippet (for /etc/apache2/conf/httpd.conf)

Ensure these ports:

Listen 8080
Listen 8443

Example VirtualHost for HTTP (8080)

<VirtualHost *:8080>
ServerName yourdomain.com
ServerAlias www.yourdomain.com

DocumentRoot /home/username/public_html

<Directory "/home/username/public_html">
AllowOverride All
Options -Indexes +FollowSymLinks
Require all granted
</Directory>

ErrorLog /var/log/apache2/yourdomain.com-error.log
CustomLog /var/log/apache2/yourdomain.com-access.log combined
</VirtualHost>

Example VirtualHost for HTTPS (8443)

<VirtualHost *:8443>
ServerName yourdomain.com
ServerAlias www.yourdomain.com

DocumentRoot /home/username/public_html

SSLEngine on
SSLCertificateFile /var/cpanel/ssl/apache_tls/yourdomain.com/combined
SSLCertificateKeyFile /var/cpanel/ssl/apache_tls/yourdomain.com/privkey

<Directory "/home/username/public_html">
AllowOverride All
Options -Indexes +FollowSymLinks
Require all granted
</Directory>

ErrorLog /var/log/apache2/yourdomain.com-ssl-error.log
CustomLog /var/log/apache2/yourdomain.com-ssl-access.log combined
</VirtualHost>

Replace:

  • yourdomain.com with your actual domain
  • username with the cPanel username
  • SSL paths with correct ones (can get via WHM > Manage SSL Hosts)

Check Ports

After saving and verifying configs:

bashCopyEditnetstat -tulpn | grep -E '8080|8443'

Should show Apache (httpd) listening on these.


Restart Services

bashCopyEdit/scripts/restartsrv_httpd
/scripts/restartsrv_nginx

Test

bashCopyEditcurl -I http://yourdomain.com
curl -I https://yourdomain.com

If NGINX is proxying correctly to Apache, both should return a 200 OK.




Leave a Reply