SOLVED NGINX as a reverse proxy: Cannot override cPanel's cpanel-proxy.conf settings

kalexan

Member
PartnerNOC
Jul 28, 2005
15
2
153
Hello.
I have recently set up NGINX as a reverse proxy using WHM at a server of mine. Some PHP applications rely on
PHP:
$_SERVER['HTTP_ACCEPT_ENCODING']
variable in order to gzip output content, however it seems that settings at /includes-optional/cpanel-proxy.conf prevent the variable from being set and passed to Apache at the following line:
NGINX:
proxy_set_header Accept-Encoding ""; # Optimize encoding
What I would like to configure is:
NGINX:
proxy_set_header Accept-Encoding $http_accept_encoding;
however, due to the conf file hierarchy set by cPanel, there is no way I can override this line. Below is an example of a user specific file (/etc/nginx/conf.d/users/USERX.conf) as set by cPanel, and it is the last "block" that is processed before passing the request to Apache:
NGINX:
### main domain for USERX##
server {
   ....
    location / {
       ...
        include conf.d/includes-optional/cpanel-proxy.conf;
        proxy_pass $scheme://$CPANEL_APACHE_PROXY_REQ_IP:$CPANEL_APACHE_PROXY_REQ_PORT;
    }
...
}
As you can see, there is no way I can override cpanel-proxy.conf. Note that includes-optional/cpanel-proxy.conf and /users/USERX.conf files are always overwritten when NGINX is updated or NGINX settings change, for example at NGINX® Manager.

Can anybody suggest a simple workaround? Do you agree that cpanel-proxy.conf should be overridable? Is there somekind of a "template" of /includes-optional/cpanel-proxy.conf that I can edit, in order to be used when cPanel updates this file?

Thank you in advance for your replies!
 
Last edited:

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
12,498
1,970
363
cPanel Access Level
Root Administrator
I confirmed this behavior on a test system and filed case CPANEL-39876 with our team to see if that is something that can be adjusted in the future. I'll be sure to update this thread once I receive an update, but it's also a good idea to keep an eye on the changelogs at Change Logs | cPanel & WHM Documentation to watch for that case number.
 
  • Like
Reactions: kalexan

cPDan

cPanel Staff
Staff member
Mar 9, 2004
724
15
243
Hello @kalexan !

You can accomplish this by putting a `.conf` file in `/etc/nginx/conf.d/includes-optional/cpanel-proxy-vendors/` that does what you want.

e.g. `/etc/nginx/conf.d/includes-optional/cpanel-proxy-vendors/my-proxy-overrides-go-here.conf`

Also, this sprint we are adding GZIP support to NGINX so in a few weeks that may simplify things for you I added this forum post to the case to update once it gets published so you’ll know about it
 
Last edited:
  • Like
Reactions: kalexan

kalexan

Member
PartnerNOC
Jul 28, 2005
15
2
153
Solution applied and worked like a charm! Should have better investigated ./includes-optional/cpanel-proxy.conf : it has a declaration that includes .conf files from ./includes-optional/cpanel-proxy-vendors/ folder at the end of it, however this folder did not physically exist, so I created it manually and placed a new .conf file with my overrides there.

Thanks @cPDan !
 
Last edited:
  • Like
Reactions: cPDan

cPDan

cPanel Staff
Staff member
Mar 9, 2004
724
15
243
Solution applied and worked like a charm! Should have better investigated ./includes-optional/cpanel-proxy.conf : it has a declaration that includes .conf files from ./includes-optional/cpanel-proxy-vendors/ folder at the end of it, however this folder did not physically exist, so I created it manually and placed a new .conf file with my overrides there.

Thanks @cPDan !
Excellent, I’m glad it worked for you! Happy to help