Nginx Reverse Proxy UDP-Verkehr (ungültiger Parameter „udp“)

Nginx Reverse Proxy UDP-Verkehr (ungültiger Parameter „udp“)

Ich versuche, einen Unifi-Controller hinter einem Nginx-Reverse-Proxy zu hosten. Das funktioniert gut, außer dass ich Probleme mit dem STUN-Protokoll habe.

Ich verwende nginx 1.18 unter Ubuntu 20.04. Wenn ich die geladenen Module für nginx überprüfe, werden sie --with-stream=dynamicals verfügbar aufgeführt, aber wenn ich versuche, sie listen 3478 udp;in meinem Serverblock zu verwenden, schlägt dies mit der folgenden Fehlermeldung fehl:

nginx: [emerg] invalid parameter "udp" in /etc/nginx/sites-enabled/stream_unifi.example.com:7

Die stream_unifi.example.comKonfiguration wird in einem streamKontext geladen:

stream {
        include /etc/nginx/sites-enabled/stream_*;
}

Übersehe ich etwas oder muss ich Nginx selbst mit einigen speziellen Flags kompilieren?

Danke schön!


Vollständige Ausgabe:

root@server:/etc/nginx/modules-available# nginx -V
nginx version: nginx/1.18.0 (Ubuntu)
built with OpenSSL 1.1.1f  31 Mar 2020
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fdebug-prefix-map=/build/nginx-5J5hor/nginx-1.18.0=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fPIC' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --modules-path=/usr/lib/nginx/modules --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-compat --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --with-http_addition_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_xslt_module=dynamic --with-stream=dynamic --with-stream_ssl_module --with-mail=dynamic --with-mail_ssl_module
root@server:/etc/nginx/modules-available# cat ../sites-available/stream_unifi.example.com
# Unifi STUN UDP Traffic
upstream unifi_stun {
        server 127.0.0.1:3478;
}

server {
    listen 3478 udp;
    include /etc/nginx/snippets/acmetool.conf;

    location / {
                proxy_pass https://unifi_stun;
        proxy_responses 0;
    }
}
root@server:/etc/nginx/modules-available# nginx -t
nginx: [emerg] invalid parameter "udp" in /etc/nginx/sites-enabled/stream_unifi.example.com:7
nginx: configuration file /etc/nginx/nginx.conf test failed
root@server:/etc/nginx/modules-available#

Antwort1

Mit meiner Konfiguration stimmten einige Dinge nicht, aber RichardSmith hat mir den richtigen Weg gezeigt.

Meins nginx.confhatte die folgenden Blöcke:

http {
        [other configuration options]
        include /etc/nginx/sites-enabled/*;
}

stream {
        [other configuration options]
        include /etc/nginx/sites-enabled/*;
}
  1. Ich habe meine „Stream-Konfiguration“ von /etc/nginx/sites-available/stream_unifi.example.comnach symbolisch verknüpft. Dies führte dazu, dass diese Konfiguration sowohl vom als auch vom Block in der oben gezeigten /etc/nginx/sites_enabled/stream_unifi.example.comübernommen wurde . Die Lösung besteht darin, den Include im Block so zu ändern, dass er wie folgt aussieht:httpstreamnginx.confstream
stream {
        include /etc/nginx/stream-sites-enabled/*;
}

Erstellen Sie dann dieses stream-sites-enabledVerzeichnis und erstellen Sie einen symbolischen Link /etc/nginx/sites-available/stream_unifi.example.comzu diesem Verzeichnis.

  1. Die Stream-Konfiguration selbst ( stream_unifi.example.com) hatte einige Probleme und muss folgendermaßen aussehen:
upstream unifi_stun {
        server 127.0.0.1:3478;
}

server {
    listen 3478 udp;
    proxy_pass unifi_stun;
    proxy_responses 0;
}

Hoffe, dass das auch für jemand anderen hilfreich ist.

verwandte Informationen