Düzeltme – WordPress Yorum Yazarı için Gerçek Yerine Localhost IP’sini (127.0.0.1) Gösteriyor

Bu eğitim, WordPress’in bir yorumun yazarı için gerçek IP adresi yerine yerel ana bilgisayar IP adresini (127.0.0.1) görüntülediği bir sorunu ele alacaktır.

Önce sorunun nedenini teşhis edeceğiz ve ardından sorunu çözmek için adım adım bir çözüm sunacağız. Ayrıca, güvenlik ve moderasyon amacıyla IP adreslerinin doğru bir şekilde izlenmesinin önemini de tartışacağız.

Bu eğitimin sonunda, sorunu çözmüş olacak ve WordPress web sitenizdeki yorumcuların IP adreslerini doğru bir şekilde takip edebileceksiniz. Bu sorunu yaşayan ve çözüm arayan herkesin mutlaka okuması gereken bir kitap.


Yani, kullanıyorsunuz Varnish? Harika! Bu yüzden ziyaretçilerinizin gerçek IP’sini göremiyorsunuz. Endişelenmeyin, işte tam çözüm.

comment author ip

Bu sorunu çözmek için,

  1. Login to FTP/SFTP
  2. Go to public_html folder
  3. Edit wp-config.php
  4. Add below code just before /* That’s all, stop editing! Happy blogging. */
  5. Save Changes.
/** Required Code for showing correct IP address */
if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { 
$xffaddrs = explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']); 
$_SERVER['REMOTE_ADDR'] = $xffaddrs[0]; 
}

Mark: Bu küçük sorunla Cloudways web hosting’de karşılaşmıştım.

Alternatif vaka

Benzer şekilde, Cloudflare kullandıktan sonra IP adresiniz yanlış görünüyorsa, işte düzeltme –

/** Correct IP in case of Cloudflare **/
if(array_key_exists('HTTP_CF_CONNECTING_IP', $_SERVER)){ 
 $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP']; 
}

Alternatif olarak, kök erişimli LEMP yığınınız varsa, Sunucu Bloğu altına aşağıdaki kuralı ekleyin. Yapılandırma dosyanızı şu adreste bulabilirsiniz /etc/nginx/sites-available/ directory.

server {
root /var/www/html;
index index.php index.html index.htm;
server_name .example.com;
# Get real IP
set_real_ip_from 0.0.0.0/0;
set_real_ip_from ::/0;
real_ip_header X-Forwarded-For;
...

Eğer wp-config.php dosyasını düzenleme konusunda rahat hissetmiyorsanız, Code Snippets eklentisini kullanarak yukarıdaki parçacığı ekleyin. İyi çalışacaktır. Umarım bu rehber doğru yönde yardımcı olur. Teşekkürler

Yorum yapın

“Düzeltme – WordPress Yorum Yazarı için Gerçek Yerine Localhost IP’sini (127.0.0.1) Gösteriyor” üzerine 18 yorum

  1. That’s the exact problem I was facing. The Cloudways support did rectify it twice but they never shared the solution. It was Mustasaam who referred me to this page.

    The solution works perfectly for me. Thank you for sharing.

    Just one more query, how did you hide the Website option from the comments box? Most of my readers are internet noobs who feel filling out the Website section is mandatory. I too want to get the same removed. Mind sharing an article on my email ID?

    Yanıtla
    • Thanks for visiting.

      To hide website field, you can use below snippet.

      // Remove URL Field
      function remove_url_comments($fields) {
      unset($fields['url']);
      return $fields;
      }
      add_filter('comment_form_default_fields','remove_url_comments');
      Yanıtla
  2. Thank you Gulshan. I thought someone is commenting from my server itself. It looks like this problem exists in Cloudways.

    Yanıtla
  3. I was looking for the same. It is showing 127.0.0.1. Fixed it. your blog seems very handy for wordpress fixes/optimizations. thanks.

    Yanıtla
  4. Hi, I’ve found your blog from shoutmeloud forum, and it’s great for optimizing wordpress.

    What plugin/code you’re using for the responsive mobile menu at the left corner of the header? I need one badly.

    Yanıtla
    • Hi,
      Thanks for coming back.

      You need to put code just before this line
      /* That's all, stop editing! Happy blogging. */

      Yanıtla