NGINX Proxy Breaks Apache Logging and Perl $ENV{'REMOTE_ADDR'}

tbutler

Active Member
Feb 11, 2004
41
5
158
After installing ea-nginx, I've noticed that I've lost $ENV{'REMOTE_ADDR'} in Perl (or rather it just shows me the server's IP address and I can't grep my way through the server's Apache error_log because there are no IP Addresses recorded. Is there a cPanel officially supported way to fix this?

I found this article on how to adjust the NGINX and Apache settings to properly forward IP addresses for Apache logging (and maybe this would help with REMOTE_ADDR, too?) but I can't figure out how to implement it in a way that doesn't require me to interact with parts of Apache's configuration that cPanel will overwrite. Hopefully there is an official way to fix this?

Thanks!
 
Last edited by a moderator:
  • Like
Reactions: mtindor

tbutler

Active Member
Feb 11, 2004
41
5
158
I found out that $ENV{'HTTP_X_REAL_IP'} is equivalent to what $ENV{'REMOTE_ADDR'} previously provided. So, my Perl scripts can gain get an accurate IP address (although it seems like it would be cleaner if cPanel configured the Nginx-Apache combo to correct REMOTE_ADDR so scripts do not need to be modified. That still doesn't solve the logging issue, however -- Apache's error_log is almost unusable for debugging if I can't do a grep for a particular IP address when trying to watch it.
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
6,148
784
313
cPanel Access Level
Root Administrator
Hey there! Our docs indicate this should be working properly of mod_remoteip is installed:


"Install the mod_remoteip Apache module. This module allows Apache to log the IP address correctly when you use NGINX as a reverse proxy."

if that is installed, could you open a ticket to have our team check this directly on the system?
 

tbutler

Active Member
Feb 11, 2004
41
5
158
I'll send in a ticket -- I installed that module, but there aren't an IP addresses written into Apache's error_log still.
 

tbutler

Active Member
Feb 11, 2004
41
5
158
Sure -- I'll do it as soon as I can log in. I have my cPanelID password saved to my password manager, but it is rejecting it this morning all the same when I try to log in, so I'm trying to reset it.
 
  • Like
Reactions: cPRex