Title: albertof's Replies | WordPress.org

---

# albertof

  [  ](https://wordpress.org/support/users/albertof/)

 *   [Profile](https://wordpress.org/support/users/albertof/)
 *   [Topics Started](https://wordpress.org/support/users/albertof/topics/)
 *   [Replies Created](https://wordpress.org/support/users/albertof/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/albertof/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/albertof/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/albertof/engagements/)
 *   [Favorites](https://wordpress.org/support/users/albertof/favorites/)

 Search replies:

## Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Simple Download Monitor] The logged IP is always the same](https://wordpress.org/support/topic/the-logged-ip-is-always-the-same/)
 *  Thread Starter [albertof](https://wordpress.org/support/users/albertof/)
 * (@albertof)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/the-logged-ip-is-always-the-same/#post-13011934)
 * Thank you
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Simple Download Monitor] The logged IP is always the same](https://wordpress.org/support/topic/the-logged-ip-is-always-the-same/)
 *  Thread Starter [albertof](https://wordpress.org/support/users/albertof/)
 * (@albertof)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/the-logged-ip-is-always-the-same/#post-12503464)
 * Hi all,
 * for those have the same issue of same IP download in Azure I realised the fix:
   
   Update the following function:
 *     ```
       function sdm_get_ip_address( $ignore_private_and_reserved = false ) {
           $flags = $ignore_private_and_reserved ? (FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) : 0;
           foreach ( array( 'HTTP_CF_CONNECTING_IP', 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR' ) as $key ) {
       	if ( array_key_exists( $key, $_SERVER ) === true ) {
       	    foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
       		$ip = trim( $ip ); // just to be safe
   
       		if ( !empty( $ip ) ) {
       			$parsed_url = parse_url( $ip );
       			$host = $parsed_url['host'];
       			if ( isset( $host ) ) {
       				if ( filter_var( $host, FILTER_VALIDATE_IP, $flags ) !== false ) {
       		 		   return $host;
       				}
       			}
       		}
       	    }
       	}
           }
           return null;
       }
       ```
   
 * Now is working on my Azure WP installation.
    Alberto
    -  This reply was modified 6 years, 2 months ago by [albertof](https://wordpress.org/support/users/albertof/).
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Simple Download Monitor] The logged IP is always the same](https://wordpress.org/support/topic/the-logged-ip-is-always-the-same/)
 *  Thread Starter [albertof](https://wordpress.org/support/users/albertof/)
 * (@albertof)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/the-logged-ip-is-always-the-same/#post-12502800)
 * Some more information:
 * article:
 * [https://docs.microsoft.com/en-us/azure/application-gateway/application-gateway-faq](https://docs.microsoft.com/en-us/azure/application-gateway/application-gateway-faq)
 * Application Gateway inserts x-forwarded-for, x-forwarded-proto, and x-forwarded-
   port headers into the request forwarded to the backend. The format for x-forwarded-
   for header is a comma-separated list of IP:Port. The valid values for x-forwarded-
   proto are http or https. X-forwarded-port specifies the port at which the request
   reached at the Application Gateway
 * Thanks.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Simple Download Monitor] The logged IP is always the same](https://wordpress.org/support/topic/the-logged-ip-is-always-the-same/)
 *  Thread Starter [albertof](https://wordpress.org/support/users/albertof/)
 * (@albertof)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/the-logged-ip-is-always-the-same/#post-12502794)
 * Hi all,
 * To respond to your question the address is relative. Anyway I did some more research
   based on the fact that my WP is hosted on azure and probably find the cause of
   the issue:
 * In the Azure Application Gateway, the http header field called ‘Remote_Addr’ 
   does not contains the actual public IP address instead it contains the private
   IP address of Azure Application Gateway.
 * The header field that contains the IP address of the incoming request is changed
   to ‘x-forwarded-for’.
 * It could be possible to test first this field before querying the Remote_Addr
   field?
 * Thanks
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Simple Download Monitor] The logged IP is always the same](https://wordpress.org/support/topic/the-logged-ip-is-always-the-same/)
 *  Thread Starter [albertof](https://wordpress.org/support/users/albertof/)
 * (@albertof)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/the-logged-ip-is-always-the-same/#post-12500874)
 * Hi,
 * Thank you for your reply.
    I’ve enabled Debug saved changes and trigger some 
   downloads. After that the log was empty. So I reset the log file and triggered
   some other download. this time the log was only containing the following:
 * 2020-03-02 21:43:40: Log has been reset.
    ——————————————————-
 * The downloads are anchor links with href of the type:
 * href=”/?smd_process_download=1&download_id=2705″>setup.msi…
 * The download counter is incremented but other information are missing.
    From 
   Log table:
 * /media/setup.msi 172.16.0.1 2020-03-02 21:46:12 Not Logged In
 * If you need more informations please let me know.
    Thank you. Alberto
    -  This reply was modified 6 years, 2 months ago by [albertof](https://wordpress.org/support/users/albertof/).
    -  This reply was modified 6 years, 2 months ago by [albertof](https://wordpress.org/support/users/albertof/).
    -  This reply was modified 6 years, 2 months ago by [albertof](https://wordpress.org/support/users/albertof/).

Viewing 5 replies - 1 through 5 (of 5 total)