Project

General

Profile

Actions

Feature #1908

closed

autoselect-random-port feature for lighttpd needed

Added by cdumke about 15 years ago. Updated 4 months ago.

Status:
Fixed
Priority:
Normal
Category:
core
Target version:
-
ASK QUESTIONS IN Forums:
No

Description

I need lighttpd to autoselect its port.

Background: I have an apache-httpd authenticating the user-session. For each user-session a lighttpd/WebDAV-process is started using the user-id of the connected user. The script starting the lighttpd writes a lighttpd.conf for the user and sets up the rewriting of the user-request in the apache-httpd. For this to work the script must either select an unused port and use it in the lighttpd.conf/server.port-option (difficult), or the lighttpd uses port 0 in its bind()-call and lets the operating system find an unused port (easy). For the second solution the script must be able to learn the port the lighttpd-process got.

I implemented the changes needed for this port-autoselect feature in my appended patch.

I added the following:

  1. lighttpd.conf has a new option "server.port-file" (value is the path the selected port is written to)
  2. the "server.port"-options has new semantics: server.port=0 means autoselect a random port, server.port=-1 means use the default port (80/443)

Files

lighttpd-1.4.21-random-port.patch (11.9 KB) lighttpd-1.4.21-random-port.patch patch implements random-port feature cdumke, 2009-02-19 15:26
Actions #1

Updated by stbuehler about 15 years ago

  • Target version changed from 1.4.21 to 1.4.22
Actions #2

Updated by stbuehler about 15 years ago

  • Target version changed from 1.4.22 to 1.4.23
Actions #3

Updated by Olaf-van-der-Spek almost 15 years ago

Wouldn't it be possible to open the port 'yourself' and then pass the descriptor to Lighttpd?
That way you could even use port 80 without starting as root.

Actions #4

Updated by cdumke almost 15 years ago

Olaf-van-der-Spek wrote:

Wouldn't it be possible to open the port 'yourself' and then pass the descriptor to Lighttpd?

How do I do that (pass an open socket to lighttpd)?
What do You mean with "descriptor"?

That way you could even use port 80 without starting as root.

Actions #5

Updated by stbuehler almost 15 years ago

  • Status changed from New to Wontfix

I don't think this feature is needed upstream. Just patch it yourself if you need such special features (as you already did), or use other ways like using a unix-socket instead of tcp (should be faster for local connections anyway).

Actions #6

Updated by Olaf-van-der-Spek almost 15 years ago

cdumke wrote:

Olaf-van-der-Spek wrote:

Wouldn't it be possible to open the port 'yourself' and then pass the descriptor to Lighttpd?

How do I do that (pass an open socket to lighttpd)?

You don't, with the current code.

What do You mean with "descriptor"?

http://www.google.com/search?q=file%20descriptor

Actions #7

Updated by gstrauss 4 months ago

  • Status changed from Wontfix to Fixed
  • Target version deleted (1.4.23)
  • ASK QUESTIONS IN Forums set to No

lighttpd can be configured to listen on a unix domain socket

lighttpd can also be configured to use already-opened socket descriptors with server.systemd-socket-activation

lighttpd can also be configured to use an already-opended descriptor on lighttpd stdin, e.g. to be run from xinetd. See running lighttpd from xinetd


The lighttpd test framework binds to an ephemeral port provided by the OS in tests/Lighttpd.pm and then starts lighttpd on that socket and port.

Actions

Also available in: Atom