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

Reverse Proxy: Difference between revisions

From ZNC
Jump to navigation Jump to search
No edit summary
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
If you want to use a subdomain for the ZNC-Webinterface, you have to create a Reverse Proxy with your webserver.<br>
If you want to use a subdomain for the ZNC-Webinterface, you have to create a Reverse Proxy with your webserver.
Without setting <code>TrustedProxy</code> 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<br>
 
If you want to see the real IP's you have to add this to your config: <br>
Note: this works for HTTP traffic only. IRC clients must connect to ZNC directly.
 
Without setting <code>TrustedProxy</code> 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:
  <nowiki>TrustedProxy = 127.0.0.1
  <nowiki>TrustedProxy = 127.0.0.1
TrustedProxy = ::1</nowiki>
TrustedProxy = ::1</nowiki>


== Nginx ==
== Nginx ==
=== As subdomain ===
  <nowiki>server {
  <nowiki>server {
     listen 80;
     listen 80;
Line 12: Line 16:


     location / {
     location / {
        proxy_pass http://[::1]:6667/;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}</nowiki>
=== As subdirectory ===
Set <code>URIPrefix</code> of the Listener in ZNC to <code>/znc/</code>
<nowiki>server {
    ...
    location /znc/ {
        proxy_pass http://127.0.0.1:1026;
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://[::1]:6667/;
     }
     }
}</nowiki>
}</nowiki>
Note there is no <code>/</code> after the port number.
== lighttpd ==
== lighttpd ==
  <nowiki>$HTTP["host"] =~ "^(sub\.domain\.com)$" {
  <nowiki>$HTTP["host"] =~ "^(sub\.domain\.com)$" {
   proxy.server = ( "" => ( ( "host" => "127.0.0.1", "port" => 6667 ) ) )
   proxy.server = ( "" => ( ( "host" => "127.0.0.1", "port" => 6667 ) ) )
}</nowiki>
}</nowiki>

Revision as of 10:55, 28 December 2017

If you want to use a subdomain for the ZNC-Webinterface, you have to create a Reverse Proxy with your webserver.

Note: this works for HTTP traffic only. IRC clients must connect to ZNC directly.

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

Nginx

As subdomain

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

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

As subdirectory

Set URIPrefix of the Listener in ZNC to /znc/

server {
    ...
    location /znc/ {
        proxy_pass http://127.0.0.1:1026;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

Note there is no / after the port number.

lighttpd

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