# remoteIP

cPanel

install the mod\_remoteip Apache module via EasyApache in WHM

Create the following file on the server:

<div id="bkmrk-1-vim-%2Fetc%2Fapache2%2Fc"><div class="cm-editor ͼ1 ͼ3 ͼ4 ͼo"><div aria-live="polite" class="cm-announced">  
</div><div class="cm-scroller" tabindex="-1"><div aria-hidden="true" class="cm-gutters"><div class="cm-gutter cm-lineNumbers"><div class="cm-gutterElement">  
</div><div class="cm-gutterElement">1</div></div></div><div aria-multiline="true" aria-readonly="true" autocapitalize="off" autocorrect="off" class="cm-content" contenteditable="true" role="textbox" spellcheck="false" translate="no"><div class="cm-line">vim /etc/apache2/conf.modules.d/370_mod_remoteip.conf</div></div><div aria-hidden="true" class="cm-layer cm-layer-above cm-cursorLayer">  
</div><div aria-hidden="true" class="cm-layer cm-selectionLayer">  
</div></div><button class="cm-copy-button" type="button"><svg height="16" viewbox="0 0 24 24" width="16" xmlns="http://www.w3.org/2000/svg"></svg></button></div></div>In here, we need to enter the addresses for proxying, in this example I'm using CloudFlare's IP ranges:

<div id="bkmrk-1-2-3-4-5-6-7-8-9-10"><div class="cm-editor ͼ1 ͼ3 ͼ4 ͼo"><div aria-live="polite" class="cm-announced">  
</div><div class="cm-scroller" tabindex="-1"><div aria-hidden="true" class="cm-gutters"><div class="cm-gutter cm-lineNumbers"><div class="cm-gutterElement">  
</div><div class="cm-gutterElement">1</div><div class="cm-gutterElement">2</div><div class="cm-gutterElement">3</div><div class="cm-gutterElement">4</div><div class="cm-gutterElement">5</div><div class="cm-gutterElement">6</div><div class="cm-gutterElement">7</div><div class="cm-gutterElement">8</div><div class="cm-gutterElement">9</div><div class="cm-gutterElement">10</div><div class="cm-gutterElement">11</div><div class="cm-gutterElement">12</div><div class="cm-gutterElement">13</div><div class="cm-gutterElement">14</div><div class="cm-gutterElement">15</div><div class="cm-gutterElement">16</div><div class="cm-gutterElement">17</div><div class="cm-gutterElement">18</div><div class="cm-gutterElement">19</div><div class="cm-gutterElement">20</div><div class="cm-gutterElement">21</div><div class="cm-gutterElement">22</div><div class="cm-gutterElement">23</div></div></div><div aria-multiline="true" aria-readonly="true" autocapitalize="off" autocorrect="off" class="cm-content" contenteditable="true" role="textbox" spellcheck="false" translate="no"><div class="cm-line">RemoteIPHeader CF-Connecting-IP</div><div class="cm-line">RemoteIPTrustedProxy 103.21.244.0/22</div><div class="cm-line">RemoteIPTrustedProxy 103.22.200.0/22</div><div class="cm-line">RemoteIPTrustedProxy 103.31.4.0/22</div><div class="cm-line">RemoteIPTrustedProxy 104.16.0.0/13</div><div class="cm-line">RemoteIPTrustedProxy 104.24.0.0/14</div><div class="cm-line">RemoteIPTrustedProxy 108.162.192.0/18</div><div class="cm-line">RemoteIPTrustedProxy 131.0.72.0/22</div><div class="cm-line">RemoteIPTrustedProxy 141.101.64.0/18</div><div class="cm-line">RemoteIPTrustedProxy 162.158.0.0/15</div><div class="cm-line">RemoteIPTrustedProxy 172.64.0.0/13</div><div class="cm-line">RemoteIPTrustedProxy 173.245.48.0/20</div><div class="cm-line">RemoteIPTrustedProxy 188.114.96.0/20</div><div class="cm-line">RemoteIPTrustedProxy 190.93.240.0/20</div><div class="cm-line">RemoteIPTrustedProxy 197.234.240.0/22</div><div class="cm-line">RemoteIPTrustedProxy 198.41.128.0/17</div><div class="cm-line">RemoteIPTrustedProxy 2400:cb00::/32</div><div class="cm-line">RemoteIPTrustedProxy 2606:4700::/32</div><div class="cm-line">RemoteIPTrustedProxy 2803:f800::/32</div><div class="cm-line">RemoteIPTrustedProxy 2405:b500::/32</div><div class="cm-line">RemoteIPTrustedProxy 2405:8100::/32</div><div class="cm-line">RemoteIPTrustedProxy 2a06:98c0::/29</div><div class="cm-line">RemoteIPTrustedProxy 2c0f:f248::/32</div></div><div aria-hidden="true" class="cm-layer cm-layer-above cm-cursorLayer">  
</div><div aria-hidden="true" class="cm-layer cm-selectionLayer">  
</div></div><button class="cm-copy-button" type="button"><svg height="16" viewbox="0 0 24 24" width="16" xmlns="http://www.w3.org/2000/svg"></svg></button></div></div>This list is correct as of April 2024, it may be worth double checking [CloudFlares IP range list ](https://www.cloudflare.com/ips-v4/)to ensure all IPs are included.

Once you've done this, we need to update the log formatting to instruct Apache to write logs correctly.

Via WHM, browse to the following page:

WHM &gt; Service Configuration &gt; Apache Configuration &gt; Global Configuration

From here we need to amend the combined and common LogFormat variables.

In short, any reference to 'h' needs to be replaced with an 'a'

Before:

<div id="bkmrk-1-%25h-%25l-%25u-%25t-%5C%22%25r%5C%22"><div class="cm-editor ͼ1 ͼ3 ͼ4 ͼo"><div aria-live="polite" class="cm-announced">  
</div><div class="cm-scroller" tabindex="-1"><div aria-hidden="true" class="cm-gutters"><div class="cm-gutter cm-lineNumbers"><div class="cm-gutterElement">  
</div><div class="cm-gutterElement">1</div></div></div><div aria-multiline="true" aria-readonly="true" autocapitalize="off" autocorrect="off" class="cm-content" contenteditable="true" role="textbox" spellcheck="false" translate="no"><div class="cm-line">%h %l %u %t \"%r\" %&gt;s %b \"%{Referer}i\" \"%{User-Agent}i\"</div></div><div aria-hidden="true" class="cm-layer cm-layer-above cm-cursorLayer">  
</div><div aria-hidden="true" class="cm-layer cm-selectionLayer">  
</div></div><button class="cm-copy-button" type="button"><svg height="16" viewbox="0 0 24 24" width="16" xmlns="http://www.w3.org/2000/svg"></svg></button></div></div>After:

<div id="bkmrk-1-%22%25a-%25l-%25u-%25t-%5C%22%25r%5C"><div class="cm-editor ͼ1 ͼ3 ͼ4 ͼo"><div aria-live="polite" class="cm-announced">  
</div><div class="cm-scroller" tabindex="-1"><div aria-hidden="true" class="cm-gutters"><div class="cm-gutter cm-lineNumbers"><div class="cm-gutterElement">  
</div><div class="cm-gutterElement">1</div></div></div><div aria-multiline="true" aria-readonly="true" autocapitalize="off" autocorrect="off" class="cm-content" contenteditable="true" role="textbox" spellcheck="false" translate="no"><div class="cm-line">"%a %l %u %t \"%r\" %&gt;s %b \"%{Referer}i\ \"%{User-Agent}i\"</div></div><div aria-hidden="true" class="cm-layer cm-layer-above cm-cursorLayer">  
</div><div aria-hidden="true" class="cm-layer cm-selectionLayer">  
</div></div><button class="cm-copy-button" type="button"><svg height="16" viewbox="0 0 24 24" width="16" xmlns="http://www.w3.org/2000/svg"></svg></button></div></div>Save the configuration and make sure Apache reloads without any issues.