Project

General

Profile

Actions

Feature #3246

closed

Allow a more flexible config-loader approach

Added by shevy 4 months ago. Updated 4 months ago.

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

Description

Hey there,

I have been using lighttpd for many years, having abandoned apache's httpd due to the changed config format. Back then I had a hardcoded config-format; when I transitioned into lighttpd, I wrote an autogenerator in ruby that would generate a config file for me, which lighttpd then loads.

I have not maintained that old ruby code in many years, though, and today when I setup my system from source (I also use ruby to compile everything from source), I got 403 errors, and I was not sure why. As I also did no longer understand the ruby code, I decided to rewrite it as well. This may take me a day or two, though.

Right now I am debugging the 403 issue, and for this, I wanted to load a minimal config for lighttpd. So my first small request is for lighttpd to perhaps have a more flexible commandline approach for loading "test" configs, but this is an aside.

Anyway. I had my old autogenerated .conf files and I wanted to load port-value and document-root, and for this I tried to load two config files via:

lighttpd -D -f $LIGHTTPD_CONFIGURATION_DIRECTORY/port.conf -f $LIGHTTPD_CONFIGURATION_DIRECTORY/document_root.conf &

This led to the following error message though:

2024-03-22 03:27:54: (server.c.1441) Can only read one config file. Use the include command to use multiple config files.

So here the error message is a bit confusing, in that I don't know what the "include command" is. Perhaps you could extend this to also show directly what is meant with the "include command", ideally a link to some lighttpd resource; and/or perhaps extend the message a bit such as, "Use the include command in a single file, in order to use multiple config files." Or something like that; right now I simply don't know what is meant with the "include command" and lighttpd should assume the user to be naive, and thus explain this a bit more in detail. But this is also an aside.

My primary request here is for lighttpd to allow for more flexibility here. If we pass multiple files, I think it would be nice if lighttpd could treat the content of these files as one big file instead. In ruby I would use e. g. File.read(); I am sure in C and C++ this is not that much harder to do.

My primary purpose is for debugging, though, so I also file this issue request more as a debugging-feature, than a "primary feature". But it may be useful for folks who, for whatever the reason, can not or do not want to use a single config file.

(Yes, my own use case is for a single config file, and I'll soon fix my own ruby scripts to autogenerate that standalone file, but as I pointed out above I need to first find out where the 403 error arises; I'll also create a new test-dummy file with all the important data lighttpd needs, so my issue will soon be resolved anyway, but I wanted to file an issue here nonetheless, because I can not, for the sake of my life, understand the rationale behind allowing ONE file, but refusing to load more than one file, when really the content is the same in the long run.)

PS: I filed it under test_component as that seemed to be the most appropriate, but in some ways this is also a feature request, just not one of the more important ones. Either way thanks for reading this.

Actions #1

Updated by gstrauss 4 months ago ยท Edited

  • Category changed from test_component to documentation
  • Status changed from New to Fixed
  • Target version deleted (1.4.xx)

So my first small request is for lighttpd to perhaps have a more flexible commandline approach for loading "test" configs, but this is an aside.

That is the -f option to specify a config file. That what it is for.

right now I simply don't know what is meant with the "include command" and lighttpd should assume the user to be naive, and thus explain this a bit more in detail. But this is also an aside.

As with most similar posts, if you have not spent 5 minutes reading the documentation before posting, then RTFM.
WikiStart
Configuration: File Syntax

My primary request here is for lighttpd to allow for more flexibility here. If we pass multiple files, I think it would be nice if lighttpd could treat the content of these files as one big file instead. In ruby I would use e. g. File.read(); I am sure in C and C++ this is not that much harder to do.

First, if you're generating a config file, then you can cat one into the other and provide a single file to lighttpd. (You already know this.)

If they are distinct, you can cat both file into a third file and provide a single file to lighttpd. (You already know this.)

lighttpd also will read the config from stdin if you use lighttpd -f -, so you have the option to feed both files to lighttpd stdin.

Since it is clear you haven't looked at the lighttpd documentation in a long while, note that Configuration: File Syntax added the := syntax in lighttpd 1.4.46 (released Oct 2017) to overwrite a prior value, e.g. server.bind := "127.0.0.1:8080".

Your "production" config could include a file glob (note: file glob) that normally does not match anything, and you can temporarily create that include file for testing purposes. Then again, if you actually understand how to test software, you won't do that in production and don't need to do that in production since it is trivial to start up lighttpd multiple ways. You might start with Configuration: Quick Start. More examples in running lighttpd from the build tree

tl;dr: RTFM

One more example: using bash <<<
lighttpd -D -f- <<<$(cat $LIGHTTPD_CONFIGURATION_DIRECTORY/*.conf) &

but I wanted to file an issue here nonetheless, because I can not, for the sake of my life, understand the rationale behind allowing ONE file, but refusing to load more than one file, when really the content is the same in the long run.

If you think this is a "required" feature, did you search to see if others have made similar feature requests? Do you think that you're the first person to suggest this "required" feature? What did you find?


In the future, I would suggest spending a few minutes reading the current documentation, and then posting more informed questions, ideas, and opinions in the lighttpd forums.
(See the Forums tab at the top of the page)

Actions #2

Updated by gstrauss 4 months ago

because I can not, for the sake of my life, understand the rationale

In case I did not get the point across above, ignorance and hyperbole are curtly dismissed; they are not a good conversation starter.

lighttpd could support multiple -f arguments, but doing so is not currently implemented. Multiple -f arguments would need to be collected and then processed in the context of a single config parser context object. lighttpd is small and light and does not cater to "implement everything". The benefits of this additional feature have not been demonstrated by the poster who failed to spend a few minutes reading the documentation and exploring the existing config options and loading methods available.

Actions

Also available in: Atom