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

조회 수: 19 (최근 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