Answer the question
In order to leave comments, you need to log in
How to listen on a range of ports in NGINX?
You need to listen on the port range 16384-32768.
The code looks like this:
server {
listen 192.168.1.4:80;
listen 192.168.1.4:16384-32768;
server_name domain.com;
location / {
proxy_pass http://192.168.1.11:$server_port;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Error service nginx restart:
-- Result: failed.
Apr 20 11:43:16 192.168.1.4 systemd[1]: Unit nginx.service entered failed state.
Apr 20 11:43:16 192.168.1.4 systemd[1]: nginx.service failed.
lines 1513-1535/1535 (END)
Apr 20 11:43:16 192.168.1.4 dhclient[3924]: send_packet: Operation not permitted
Apr 20 11:43:16 192.168.1.4 kernel: Firewall: *UDP_OUT Blocked* IN= OUT =eth0 SRC=192.168.1.4 DST=192.168.1.1 LEN=328 TOS=0x00
Apr 20 11:43:16 192.168.1.4 dhclient[3924]: dhclient.c:2688: Failed to send 300 byte long packet over fallback interface.
Apr 20 11:43:16 192.168.1.4 systemd[1]: Cannot add dependency job for unit rpcbind.socket, ignoring: Unit not found.
Apr 20 11:43:16 192.168.1.4 systemd[1]: Starting The nginx HTTP and reverse proxy server...
-- Subject: Starting nginx.service unit
-- Defined-By: systemd
-- Support: lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Starting process of starting nginx.service unit.
Apr 20 11:43:16 192.168.1.4 nginx[25095]: nginx: [emerg] invalid port in "192.168.1.4:16384-32768" of the "listen" directive
Apr 20 11:43:16 192.168.1.4 nginx[ 25095]: nginx: configuration file /etc/nginx/nginx.conf test failed
Apr 20 11:43:16 192.168.1.4 systemd[1]: nginx.service: control process exited, code=exited status=1
Apr 20 11: 43:16 192.168.1.4 systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
-- Subject: nginx.service unit failed
-- Defined-By: systemd
-- Support:lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The nginx.service unit failed.
Answer the question
In order to leave comments, you need to log in
nginx.org/en/docs/stream/ngx_stream_core_module.ht...
Port ranges (1.15.10) are specified with the first and last port separated by a hyphen:
listen 127.0.0.1:12345-12399;
listen 12345-12399;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question