Webadmin Shows Localhost (127.0.0.1) When Loading through Nginx Proxy #412

Closed
opened 2026-10-05 04:19:12 +02:00 by adam · 4 comments
Owner

When using Nginx to proxy the webadmin so it can bind to port 80 (Without running as root), it shows the localhost IP of 127.0.0.1 when logging in and out. I have Nginx is a proper proxy setup where it passes the real IP of the user to the Webadmin.

My Nginx config:

server {
  listen 80;
  listen [::]:80;

  server_name DOMAIN.TLD;

  #add_header Strict-Transport-Security "max-age=31536000";

  return 301 https://$server_name$request_uri;
}

server {
  listen 443 ssl spdy;
  listen [::]:443 ssl spdy;

  index index.html index.htm;

  server_name DOMAIN.TLD;

  # Logging
  access_log /srv/http/DOMAIN.TLD/log/access.log;
  error_log /srv/http/DOMAIN.TLD/log/error.log warn;

  # Custom Stuff
  ssl_certificate /etc/nginx/ssl/znc.crt;
  ssl_certificate_key /etc/nginx/ssl/znc.key;

  location ~ /\. {
    deny all;
  }

  location / {
    proxy_set_header X-Real-IP  $remote_addr;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header Host $host;
    proxy_pass https://127.0.0.1:5000;
  }
}

As for ZNC, I have it set to only bind the webadmin to localhost on port 5000. It works correctly, all except it is displaying the wrong IP (Image attached).

screen shot 2014-11-06 at 12 20 20 pm

EDIT: This is ZNC v1.4.

When using Nginx to proxy the webadmin so it can bind to port 80 (Without running as root), it shows the localhost IP of 127.0.0.1 when logging in and out. I have Nginx is a proper proxy setup where it passes the real IP of the user to the Webadmin. My Nginx config: ``` server { listen 80; listen [::]:80; server_name DOMAIN.TLD; #add_header Strict-Transport-Security "max-age=31536000"; return 301 https://$server_name$request_uri; } server { listen 443 ssl spdy; listen [::]:443 ssl spdy; index index.html index.htm; server_name DOMAIN.TLD; # Logging access_log /srv/http/DOMAIN.TLD/log/access.log; error_log /srv/http/DOMAIN.TLD/log/error.log warn; # Custom Stuff ssl_certificate /etc/nginx/ssl/znc.crt; ssl_certificate_key /etc/nginx/ssl/znc.key; location ~ /\. { deny all; } location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; proxy_pass https://127.0.0.1:5000; } } ``` As for ZNC, I have it set to only bind the webadmin to localhost on port 5000. It works correctly, all except it is displaying the wrong IP (Image attached). ![screen shot 2014-11-06 at 12 20 20 pm](https://cloud.githubusercontent.com/assets/2458289/4940313/3bc0b4ac-65d9-11e4-808b-e296f6aaa227.png) EDIT: This is ZNC v1.4. <!-- github-sync-id:47989247 -->
adam closed this issue 2026-10-05 04:19:12 +02:00
Author
Owner

I'm guessing that ZNC doesn't check/listen for the X-Forwarded-For or X-Real-IP headers...

I'm guessing that ZNC doesn't check/listen for the X-Forwarded-For or X-Real-IP headers... <!-- github-comment-id:62016915 -->
Author
Owner
Duplicate of: https://github.com/znc/znc/issues/177 & https://github.com/znc/znc/issues/317 Fixed by: https://github.com/znc/znc/pull/349 <!-- github-comment-id:62017267 -->
Author
Owner

<harpyon> Okay, here's what I did, jreese: Build ZNC 1.5 (git), add "TrustedProxy = 127.0.0.1" to root znc.conf, and "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;" to nginx conf. It werkz!

https://github.com/znc/znc/issues/177

This is in 1.5 git

`<harpyon> Okay, here's what I did, jreese: Build ZNC 1.5 (git), add "TrustedProxy = 127.0.0.1" to root znc.conf, and "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;" to nginx conf. It werkz!` https://github.com/znc/znc/issues/177 This is in 1.5 git <!-- github-comment-id:62017300 -->
Author
Owner

Ah, ok. Thanks!

Ah, ok. Thanks! <!-- github-comment-id:62017803 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/znc#412