Set MATLAB Web App Server Port number to below 1024 on Linux

20 次查看(过去 30 天)
I want to use port 80 for my web app server on Linux. But web app cannot start. It reports below error in the log file
00000014 2023-05-18 12:15:08 0x00007faf377fe700 agent::spf::legacyservicepublisher V Exception caught: Dynamic exception type: foundation::http::TCPConfigurationError
std::exception::what: Failed to open server socket on 0.0.0.0, for given port range: [80,80]
I am pretty sure port 80 is not being used by other service.

采纳的回答

MathWorks Support Team
MathWorks Support Team 2025-8-29,0:00
编辑:MathWorks Support Team 2025-8-29,18:36
By default, ip_unprivileged_port_start is set to 1024 in Linux. It defines the first unprivileged port in the network namespace. Privileged ports require root or CAP_NET_BIND_SERVICE in order to bind to them. This is why you cannot set web app server to use port 80, or any value below 1024 if you have default ip_unprivileged_port_start value.
To workaround this:
Use port forwarding with command "sudo iptables -t nat -A PREROUTING -p tcp --dport $external_port -j REDIRECT --to-ports $server_site_port". For example your web app server is set to port 9988 and you want to access it with port 80 in the url. The command is "sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 9988"
Alternatively, you can allow listening on all privileged ports using this commands "sudo sysctl net.ipv4.ip_unprivileged_port_start=0".

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Web App Server 的更多信息

标签

尚未输入任何标签。

产品


版本

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by