To create new wiki account, please join us on #znc at freenode and ask admins to create a wiki account for you. You can say thanks to spambots for this inconvenience.

Reverse proxy

From ZNC
Jump to: navigation, search

Reverse proxy works only to access web interface with browser, but not to connect with IRC client.

Support for reverse proxies (specifically, settings TrustedProxy and URIPrefix) is available since 1.6.0.

Without setting TrustedProxy in your config you will only see 127.0.0.1 or ::1 for each web-access in your logs => You can't block specific IP's
If you want to see the real IP's you have to add this to your config:

TrustedProxy = 127.0.0.1
TrustedProxy = ::1

Only connections from the listed hosts will use X-Forwarded-For header.

As a subdomain

Using znc.domain.tld as an example.

Nginx

server {
    listen 80;
    listen [::]:80;
    server_name znc.domain.tld;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://[::1]:6667/;
    }
}

lighttpd

$HTTP["host"] =~ "^(sub\.domain\.com)$" {
  proxy.server = ( "" => ( ( "host" => "127.0.0.1", "port" => 6667 ) ) )
}


As a subURL

Using domain.tld/znc as an example.

Note: Due to a bug in version 1.6.2 and lower, you will need to enter a trailing slash in the URL to access the Webinterface. eg: www.domain.tld/znc/. This is fixed in later versions.

Make sure URIPrefix for the listener is set to /znc/. This setting is available in webadmin, and in /msg *status AddPort. This setting works even without reverse proxy, so you can first make sure that it works while accessing ZNC's port directly, and then configure access via the reverse proxy.

Nginx

You will most likely be adding this block to an already existing config, so you won't need to copy these listen and server_name directives.

server {
    listen 80;
    listen [::]:80;
    server_name domain.tld;

    location /znc {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://[::1]:6667;
    }
}