Hello.
Dietpi on PC.
I use it for wordpress web server with Lets Encrypt etc.
I just tried to add a vhost (i already have 3 vhosts working ok) but after setup (db,vhost on conf-enabled,ssl with certbot) when i visit the site it says that ssl is invalid because it reads ssl from letsencrypt.conf and not from e.g example.com.conf.
Anyone knows why is it happening.
And i want to test if issue happens because of mods in lighttpd.conf
Did anyone have the default lighttpd.conf file for dietpi
Many thanks for your report.
Your run all vhosts on different ports? /etc/lighttpd/conf-enabled/letsencrypt.conf is the 443 vhost, hence will always be in charge when a request to port 443 is incoming, in no other case.
If you enabled it, there is /etc/lighttpd/conf-enabled/redirect.conf which redirects HTTP to HTTPS for all vhosts/ports but it should preserve the vhost/port. But I never tested it myself to be true, hence you might want to test if the issue appears as well if you explicitly connect via https://.
All vhosts conf files start with $HTTP["host"] == "example.com" {
they are on the same (443) port but it goes by hostmane e.g you look for
in each conf file there is
example1,2,3 .conf files are placed inside conf-enabled directory
Is there any place to find default files that dietpi uses for:
Okay so since all your vhosts listen on 443, letsencrypt.conf is used for all of them. I'm not 100% sure which directive overrides which one ($SERVER["socket"] vs $HTTP["host"]) or if its only a question of alphabetical order.
If you have HTTPS redirect active, easiest is probably to:
letsencrypt.conf: https://github.com/MichaIng/DietPi/blob/3f63e4d7497fd4dcae62a530bd2b2e3425a9db81/dietpi/dietpi-letsencrypt#L142-L143$SERVER["socket"] == ":443", so they're HTTPS-only, while redirect.conf redirects all plain HTTP requests. Although you say "they are on the same (443) port", so this seems to be already the case?I make some test before your answer.
I read the so obvious README file inside /etc/lighttpd/conf-available/
which says:
If you want to create your own files they names should be
build as nn-name.conf where "nn" is two digit number (number
is used to find order for loading files)
So i 've renamed all files for vhosts including redirect & letsencrypt.conf with "nn-" at start and thats it!!!
And to mention: the problem doesn`t exist when 3 vhost enabled but after 4th vhost it reads ssl (only for vhost 4, the others are working ok) from letsencrypt.conf causing invalid certificate error.
BTW thank you for your help!
Okay so this means the alphabetical order of your configs was like this?:
next.exampleN.conf vhosts were parsed after letsencrypt.conf, hence their ssl.pemfile + ssl.ca-file were effective.
example.conf vhost was parsed before letsencrypt.conf, hence its ssl.pemfile + ssl.ca-file was overwritten and ineffective?
Those file names were never touched since the initial dietpi-letsencrypt creation while meanwhile we follow the nn- priority-naming convention. It makes sense to give this global letsencrypt.conf a pretty low priority (i.e. 00-letsencrypt.conf if no module ships related directives with higher priority) so that any custom vhost/config overrides it.
redirect.conf on the other hand needs to have highest priority (i.e. 98-redirect.conf, to still allow admin overrides via 99-) to effectively redirect each and every non-HTTPS request.
Exactly!!! The names were:
You can use 50-redirect.conf if anyone wants an ascending order for vhosts there is some space before and after, and if someone don't bother 50 or 99 he goes either way after redirect.conf
Done: https://github.com/MichaIng/DietPi/pull/3734
Renaming those on running systems, accidentally merged into dev directly 馃槃: https://github.com/MichaIng/DietPi/commit/5e993ecabf056d2fcde57ab0f62547c50021a340
Most helpful comment
Exactly!!! The names were:
You can use
50-redirect.confif anyone wants an ascending order for vhosts there is some space before and after, and if someone don't bother 50 or 99 he goes either way after redirect.conf