NGINX as a reverse proxy: Cannot override cPanel's cpanel-proxy.conf settings
Hello.
I have recently set up NGINX as a reverse proxy using WHM at a server of mine. Some PHP applications rely on
[CODE=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: [CODE=nginx]proxy_set_header Accept-Encoding ""; # Optimize encoding
What I would like to configure is: [CODE=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: [CODE=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!
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: [CODE=nginx]proxy_set_header Accept-Encoding ""; # Optimize encoding
What I would like to configure is: [CODE=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: [CODE=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!
-
Hello! I will look into this and get back to you. 0 -
Hello! Any news on this? 0 -
Hey there - it looks like cPanelAnthony didn't get to this. I've reached out to our webserver team to see what the options are and I'll post a reply once I have more details. 0 -
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. 0 -
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 0 -
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 ! 0 -
Thanks @cPDan !!! 0 -
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 help0
Please sign in to leave a comment.
Comments
8 comments