nginx 리버스 프록시 뒤에서 Unifi 컨트롤러를 호스팅하려고 합니다. STUN 프로토콜에 문제가 있다는 점을 제외하면 이것은 잘 작동합니다.
Ubuntu 20.04에서 nginx 1.18을 사용하고 있습니다. nginx에 대해 로드된 모듈을 확인하면 --with-stream=dynamic
사용 가능한 것으로 표시되지만 내 서버 블록에서 사용하려고 하면 listen 3478 udp;
다음 오류 메시지와 함께 실패합니다.
nginx: [emerg] invalid parameter "udp" in /etc/nginx/sites-enabled/stream_unifi.example.com:7
구성 은 컨텍스트 stream_unifi.example.com
에 로드됩니다 stream
.
stream {
include /etc/nginx/sites-enabled/stream_*;
}
제가 누락한 것이 있나요? 아니면 일부 특수 플래그를 사용하여 nginx를 직접 컴파일해야 합니까?
감사합니다!
전체 출력:
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#
답변1
내 구성에 몇 가지 문제가 있었는데 RichardSmith가 나에게 올바른 방향을 알려줬습니다.
내 nginx.conf
블록은 다음과 같습니다.
http {
[other configuration options]
include /etc/nginx/sites-enabled/*;
}
stream {
[other configuration options]
include /etc/nginx/sites-enabled/*;
}
/etc/nginx/sites-available/stream_unifi.example.com
내 "스트림 구성"을 에서 으로 심볼릭 링크했습니다/etc/nginx/sites_enabled/stream_unifi.example.com
. 이로 인해 이 구성은 위에 표시된 블록http
과 블록 모두에서 선택되었습니다 . 해결 방법은 블록의 포함을 다음과 같이 변경하는 것입니다.stream
nginx.conf
stream
stream {
include /etc/nginx/stream-sites-enabled/*;
}
그런 다음 이 stream-sites-enabled
디렉터리를 만들고 /etc/nginx/sites-available/stream_unifi.example.com
해당 디렉터리에 심볼릭 링크를 연결합니다.
- 스트림 구성 자체(
stream_unifi.example.com
)에는 몇 가지 문제가 있었고 다음과 같아야 합니다.
upstream unifi_stun {
server 127.0.0.1:3478;
}
server {
listen 3478 udp;
proxy_pass unifi_stun;
proxy_responses 0;
}
다른 사람에게도 도움이 되기를 바랍니다.