Giter Club home page Giter Club logo

Comments (4)

tschettervictor avatar tschettervictor commented on June 30, 2024 1

Excellent.
I’m linking to a thread with two possible solutions.
Solution

from caddy-cgi.

aksdb avatar aksdb commented on June 30, 2024

If binding to port 80 is your only reason for running as root, you should look into capabilities and especially the capability CAP_NET_BIND_SERVICE. If your service is run with that, it is allowed to bind to priviledges ports even if it is not root.

from caddy-cgi.

tschettervictor avatar tschettervictor commented on June 30, 2024

I have other reason, like security.
It’s just easier to run caddy as root.

Possible to set the uid/gid for the cgi process maybe?

Maybe run caddy as root then switch to www?

I’m on FreeBSD btw

from caddy-cgi.

aksdb avatar aksdb commented on June 30, 2024

I have other reason, like security.

Security should be higher when not run as root.
I have not enough knowledge to advice on best practices for FreeBSD though. So I'll have to take your word for it.

Possible to set the uid/gid for the cgi process maybe?

Not without bigger rework or less code-reuse. The cgi.Handler doesn't allow customizing the os.exec calls. So I would have to replicate (or copy and then modify) the whole cgi package just to pass another parameter to the process creation.

Maybe run caddy as root then switch to www?

Not that I am aware of. I think in the age of containers and cgroups, there is simply no good reason to trust a process with forking itself into a lesser-priviledged child process.

So IMO you have these options:

  • Find out, why the script behaves differently when run as root vs non-root. Maybe it has a "am I root"-check and denies running then?
  • Wrap the script with something like sudo to run it as a different user.
  • Run Caddy with less privileges (as a container or something similar ... whatever FreeBSD offers for that).
  • Run a second Caddy with less privileges and reverse-proxy to it.

from caddy-cgi.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.