Changes to 'Listen' httpd.conf directives lost after every rebuild

babakb

Well-Known Member
Jan 20, 2007
47
0
156
We need to specify Apache to listen on specific IP's and ports. e.g.

Listen 127.0.0.1:80
Listen XXX.XXX.132.12:82
Listen XXX.XXX.132.13:82
... etc ...

The settings are lost everytime httpd.conf rebuillds. We've tried:

/usr/local/cpanel/bin/apache_conf_distiller --update

No success. Doesn't look like the distiller retains the 'Listen' httpd.conf directives. Any solution?
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
You will likely need to change the Listen directives in /var/cpanel/templates/apache2/main.default by copying it to /var/cpanel/templates/apache2/main.local location, then hardcoding the ones you want into that file. Here are the entries you'd be changing:

Code:
[% IF configured.ip_listen -%]
[%- FOREACH ip IN configured.ip_listen -%]
Listen [% ip %]:[% configured.main_port %]
[% END -%]
[% ELSE -%]
# Defined in /var/cpanel/cpanel.config: apache_port
Listen [% main.listen.item.listen %]
[% END -%]

[% IF configured.ip_listen_ssl -%]
[%- FOREACH ip IN configured.ip_listen_ssl -%]
    Listen [% ip %]:[% configured.main_port_ssl %]
[% END -%]
[% ELSE -%]
    # Defined in /var/cpanel/cpanel.config: apache_ssl_port
    Listen [% main.ifdefinessl.listen.item.listen %]
[% END -%]
Afterward, then just run the following:

Code:
/scripts/rebuildhttpdconf
/etc/init.d/httpd restart
I am not aware of any other way for those to be hard-coded without being overwritten on EasyApache recompile or httpd rebuild.

Thanks!v