Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mono: Is it possible to run a service on port 80 without root?

Is there a way to get an app to run on port 80 without being forced to run it as root?

I don't want to run the process as root because that's insecure, and I want to use port 80. I don't want to use a proxy in front of the app.

Apache for example starts as root and drops privileges, is there a way to achieve this in Mono?

For context I'm running ServiceStack, but I'm asking in general as well.

like image 978
Amir Abiri Avatar asked Jan 13 '23 06:01

Amir Abiri


1 Answers

OK I finally accomplished this using authbind

Worked like a charm. Only thing to note is that you MUST use the --deep switch since mono actually runs another process. That was an annoying gotcha that wasted an hour or so.

So final command looks something like:

sudo -u myapp authbind --deep ./MyApp.exe

I used the by uid approach of authbind so this is the config:

/etc/authbind/byuser/999:

0.0.0.0,80-89

The bottom line is that trying to find an answer to this question in the context of Mono only is futile - simply replace "Mono" with "Java" in your searches and the solutions for Java/Tomcat are mostly applicable to Mono as well.

like image 193
Amir Abiri Avatar answered Jan 19 '23 12:01

Amir Abiri