Sub-domains not working

1. The problem I’m having:

I am trying to make sub-domains work

2. Error messages and/or full log output:

PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.
```
no error message
```

3. Caddy version:

2.10.2

4. How I installed and ran Caddy:

with bash shell, long time ago.
all sites & logs are working fine

a. System environment:

Linux Ubuntu 24.04, w. Systemd

b. Command:

caddy has been running fine for months/years
PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.

c. Service/unit/compose file:

n/a
PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.

d. My complete Caddy config:

{
	debug
	email webtek@hyperbase.com
}
(dynamic)  {
	handle /xml/* {
		reverse_proxy localhost:3000
	}
}
hyperbase.com www.hyperbase.com {
	import dynamic
	handle * {
		root /var/www/html/hyperlib/hyperbase/
		file_server
	}
	log {
		output file /var/log/caddy/hyperbase.json
		format json
	}
}
stratml.hyperbase.com {
	import dynamic
	handle * {
		root /var/www/html/hyperform/stratml/
		file_server
	}
	log {
		output file /var/log/caddy/stratml.json
		format json
	}
}
dnaos.com www.dnaos.com distributed.solutions www.distributed.solutions {
	import dynamic
	handle * {
		root /var/www/html/hyperlib/dnaos/
		file_server
	}
	log {
		output file /var/log/caddy/dnaos.json
		format json
	}
}
01communications.com www.01communications.com 01communications.org www.01communications.org {
	import dynamic
	handle * {
		root /var/www/html/hyperlib/com01/
		file_server
	}
	log {
		output file /var/log/caddy/com01.json
		format json
	}
}
cosmos-square.com www.cosmos-square.com cosmossquare.com www.cosmossquare.com square-cosmos.com www.square-cosmos.com squarecosmos.com www.squarecosmos.com {
	import dynamic
	handle * {
		root /var/www/html/hyperlib/c2/
		file_server
	}
	log {
		output file /var/log/caddy/c2.json
		format json
	}
}
telepathmedia.com www.telepathmedia.com {
	import dynamic
	handle * {
		root /var/www/html/hyperlib/telepath/
		file_server
	}
	log {
		output file /var/log/caddy/telepath.json
		format json
	}
}
editionsconsonance.com www.editionsconsonance.com consonancepublishing.com www.consonancepublishing.com {
	import dynamic
	handle * {
		root /var/www/html/hyperlib/consonance/
		file_server
	}
	log {
		output file /var/log/caddy/consonance.json
		format json
	}
}
accordeon101.com www.accordeon101.com accordion101.com www.accordion101.com {
	import dynamic
	handle * {
		root /var/www/html/hypermedia/accordeon/
		file_server
	}
	log {
		output file /var/log/caddy/accordeon.json
		format json
	}
}
musicnovatory.com www.musicnovatory.com novatoire.com www.novatoire.com {
	import dynamic
	handle * {
		root /var/www/html/hypermedia/musnov/
		file_server
	}
	log {
		output file /var/log/caddy/musnov.json
		format json
	}
}
musicphenomenon.com www.musicphenomenon.com tunetuneup.com www.tunetuneup.com {
	import dynamic
	handle * {
		root /var/www/html/hypermedia/mup-en/
		file_server
	}
	log {
		output file /var/log/caddy/mup-en.json
		format json
	}
}
phenomenemusique.com www.phenomenemusique.com {
	import dynamic
	handle * {
		root /var/www/html/hypermedia/mup-fr/
		file_server
	}
	log {
		output file /var/log/caddy/mup-fr.json
		format json
	}
}
grosbonchant.com www.grosbonchant.com {
	import dynamic
	handle * {
		root /var/www/html/hypermedia/gbc/
		file_server
	}
	log {
		output file /var/log/caddy/gbc.json
		format json
	}
}
knowledgearchitect.org www.knowledgearchitect.org knowledgearchitecture.solutions www.knowledgearchitecture.solutions {
	import dynamic
	handle * {
		root /var/www/html/hyperform/kao/
		file_server
	}
	log {
		output file /var/log/caddy/kao.json
		format json
	}
}
kebek.org www.kebek.org prosperite-solidarite.org www.prosperite-solidarite.org {
	import dynamic
	handle * {
		root /var/www/html/hyperform/kebek/
		file_server
	}
	log {
		output file /var/log/caddy/kebek.json
		format json
	}
}
prosperity-solidarity.org www.prosperity-solidarity.org {
	import dynamic
	handle * {
		root /var/www/html/hyperform/sps/
		file_server
	}
	log {
		output file /var/log/caddy/sps.json
		format json
	}
}
andrecusson.com www.andrecusson.com {
	import dynamic
	handle * {
		root /var/www/html/hypermall/akhu/
		file_server
	}
	log {
		output file /var/log/caddy/akhu.json
		format json
	}
}
akhusono.com www.akhusono.com {
	import dynamic
	handle * {
		root /var/www/html/hypermall/sono/
		file_server
	}
	log {
		output file /var/log/caddy/sono.json
		format json
	}
}
aki.akhusono.com {
	import dynamic
	handle * {
		root /var/www/html/hypermall/sono/english.html
		file_server
	}
	log {
		output file /var/log/caddy/aki.json
		format json
	}
}
ica.akhusono.com {
	import dynamic
	handle * {
		root /var/www/html/hypermall/sono/francais.html
		file_server
	}
	log {
		output file /var/log/caddy/ica.json
		format json
	}
}
michelperrault.com www.michelperrault.com {
	import dynamic
	handle * {
		root /var/www/html/hypermall/pero/
		file_server
	}
	log {
		output file /var/log/caddy/pero.json
		format json
	}
}
conradletendre.com www.conradletendre.com {
	import dynamic
	handle * {
		root /var/www/html/hypermall/letendre/
		file_server
	}
	log {
		output file /var/log/caddy/letendre.json
		format json
	}
}
jeanchatillon.com www.jeanchatillon.com {
	import dynamic
	handle * {
		root /var/www/html/hypermall/chatillon/
		file_server
	}
	log {
		output file /var/log/caddy/chatillon.json
		format json
	}
}
PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.

5. Links to relevant resources:

n/a

Well, that’s a pretty broad statement without any supporting details.

Could you clarify what exactly isn’t working? What behaviour are you seeing, or what were you expecting to happen? What tests have you run that led you to that conclusion?

1 Like

Hi Timelord,

I had an account here months ago and seem to have lost it., so I created a new one.

I have been fighting with the online form and had to do it over a few times. My explanations grew shorter each time.

As per the Caddyfile, I have tried to define 3 sub-domains (stratml on hyperbase.com, and aki & ica on akhusono.com). The domains for these sub-domains have been working fine for quite some time, but not the sub-domains. There is no error message, they just don’t connect (page not found (404)). On the corresponding domain DNS config, I have defined CNAME aliases for each the sub-domains.

I am trying to figure out what I am missing for the sub-domains to work.

Thank you for your help and understanding.

Akhu

1 Like

Alright, this is something we can work with.

I’m seeing an HTTP 200 on https://hyperbase.com, but an HTTP 404 on https://stratml.hyperbase.com. Let’s focus on that for now.

Could you run the following commands and share the output?

Check which user Caddy is running as:

ps aux | grep '[c]addy'

Check file permissions for the hyperbase.com site. Since this one is working, I want to use it to establish a baseline:

ls -lad /var/www/html/hyperlib
ls -la  /var/www/html/hyperlib/hyperbase

Now check file permissions for the stratml.hyperbase.com site:

ls -lad /var/www/html/hyperform
ls -la  /var/www/html/hyperform/stratml

I have a feeling the issue might be related to file permissions.

Could you also explain what you’re trying to achieve here? I just want to make sure I understand your setup correctly. Are these two files or directories?

/var/www/html/hypermall/sono/english.html
/var/www/html/hypermall/sono/francais.html

Hi Timelordx,

No, Not yet, they are the “index.html” files for the two versions (English & French) of that site, currently all sitting in the same folder.

As for your previous questions, each is followed by its results, here below. The last one is a little heavy …

In fact, it has 200k too many characters to fit here, as there are over 20000 files and folders

(with lots more files) in that folder.

Alright, this is something we can work with.

I’m seeing an HTTP 200 on https://hyperbase.com, but an HTTP 404 on https://stratml.hyperbase.com. Let’s focus on that for now.

Could you run the following commands and share the output?

Check which user Caddy is running as:

ps aux | grep '[c]addy'

**caddy 3271 0.3 0.1 1275096 60572 ? Ssl 2025 58:13 /usr/bin/caddy run --environ --config /etc/caddy/Caddyfile

**

Check file permissions for the hyperbase.com site. Since this one is working, I want to use it to establish a baseline:

ls -lad /var/www/html/hyperlib
drwxr-xr-x 9 root root 4096 déc.  30 02:28 /var/www/html/hyperlib

ls -la  /var/www/html/hyperlib/hyperbasedrwxr-xr-x 3 root root  4096 déc.  30 02:21  .

drwxr-xr-x 9 root root  4096 déc.  30 02:28  ..

-rwxr-xr-x 1 root root 13958 déc.  30 02:21  alphamap.html

drwxr-xr-x 6 root root  4096 déc.  30 02:21  asset

-rwxr-xr-x 1 root root  2131 déc.  30 02:21  blank.html

-rwxr-xr-x 1 root root 31259 déc.  30 02:21  boutique-en.html

-rwxr-xr-x 1 root root 31301 déc.  30 02:21  boutique-fr.html

-rwxr-xr-x 1 root root  2854 déc.  30 02:21  construction.html

-rwxr-xr-x 1 root root  4570 déc.  30 02:21  englishroller.html

-rwxr-xr-x 1 root root  6149 déc.  30 02:21  entryroller.html

-rwxr-xr-x 1 root root  2238 déc.  30 02:21  favicon.ico

-rwxr-xr-x 1 root root  2034 déc.  30 02:21  frameset.html

-rwxr-xr-x 1 root root  4672 déc.  30 02:21  frenchroller.html

-rwxr-xr-x 1 root root 13018 déc.  30 02:21  guide.html

-rwxr-xr-x 1 root root 10278 déc.  30 02:21  hyperapps.html

-rwxr-xr-x 1 root root 36666 déc.  30 02:21  hyperbase.html

-rwxr-xr-x 1 root root 14134 déc.  30 02:21  hyperefs.html

-rwxr-xr-x 1 root root 17666 déc.  30 02:21  hyperhost.html

-rwxr-xr-x 1 root root  7954 déc.  30 02:21  hyper.html

-rwxr-xr-x 1 root root 10285 déc.  30 02:21  hyperlinks.html

-rwxr-xr-x 1 root root  9766 déc.  30 02:21 'hypernews - Copie.html'

-rwxr-xr-x 1 root root 10278 déc.  30 02:21  hypernews.html

-rwxr-xr-x 1 root root 10332 déc.  30 02:21  hyperportal.html

-rwxr-xr-x 1 root root 12977 déc.  30 02:21  idmap.html

-rwxr-xr-x 1 root root  2830 déc.  30 02:21  index.html

-rwxr-xr-x 1 root root 15795 déc.  30 02:21  search.html

-rwxr-xr-x 1 root root 13094 déc.  30 02:21  sitemap.html

-rwxr-xr-x 1 root root  6144 déc.  30 02:21  Thumbs.db

-rwxr-xr-x 1 root root 28000 déc.  30 02:21  useterms.html

-rwxr-xr-x 1 root root  3170 déc.  30 02:21  xindex.xhtml




Now check file permissions for the stratml.hyperbase.com site:

ls -lad /var/www/html/hyperform
drwxr-xr-x 7 root root 4096 déc.  30 02:29 /var/www/html/hyperform




ls -la  /var/www/html/hyperform/stratml
total 20340

drwxr-xr-x 2571 root root  94208 déc.  30 01:57  .

drwxr-xr-x    7 root root   4096 déc.  30 02:29  ..

-rwxr-xr-x    1 root root   4253 déc.  30 01:57  12TPSR.html

-rwxr-xr-x    1 root root   4235 déc.  30 01:57  18F.html

drwxr-xr-x    2 root root   4096 déc.  30 01:57  4P4BPS

-rwxr-xr-x    1 root root   4253 déc.  30 01:57  4P4BPS.html

drwxr-xr-x    2 root root   4096 déc.  30 01:57  4PSC

-rwxr-xr-x    1 root root   4241 déc.  30 01:57  4PSC.html

drwxr-xr-x    2 root root   4096 déc.  30 01:57  4TCL

-rwxr-xr-x    1 root root   4241 déc.  30 01:57  4TCL.html

drwxr-xr-x    2 root root  12288 déc.  30 01:57  5SCDM

-rwxr-xr-x    1 root root   4247 déc.  30 01:57  5SCDM.html

drwxr-xr-x    2 root root   4096 déc.  30 01:57  5SLOD

-rwxr-xr-x    1 root root   4247 déc.  30 01:57  5SLOD.html

drwxr-xr-x    2 root root  12288 déc.  30 01:57  6Q2MEP

-rwxr-xr-x    1 root root   4253 déc.  30 01:57  6Q2MEP.html

drwxr-xr-x    2 root root   4096 déc.  30 01:57  6W2EE
...
1 Like

Re: stratml.hyperbase.com

There’s nothing wrong with your file permissions or your general setup. The issue is that there’s no index file in /var/www/html/hyperform/stratml.

When you visit https://stratml.hyperbase.com, Caddy looks for index.html or index.txt in that directory. Since it doesn’t find one, it returns an HTTP 404, which is expected behaviour.

However, when you go to https://stratml.hyperbase.com/4PSC.html, it works fine.

So your options are:

  1. Add an index file (index.html) to /var/www/html/hyperform/stratml, or
  2. Choose one of the existing files to serve when someone visits https://stratml.hyperbase.com, or
  3. Make /var/www/html/hyperform/stratml browsable (not recommended).

For options 1 and 3, check the file_server directive, especially the index and browse options:

For option 2, look into the try_files directive:

Re: aki.akhusono.com and ica.akhusono.com:

You can’t use a file in the root directive. root must point to a directory.

If you want to ALWAYS respond with the contents of english.html or francais.html, you can do something like this:

aki.akhusono.com {
	import dynamic
	handle * {
		rewrite /english.html
		root /var/www/html/hypermall/sono
		file_server
	}
	log {
		output file /var/log/caddy/aki.json
		format json
	}
}
ica.akhusono.com {
	import dynamic
	handle * {
		rewrite /francais.html
		root /var/www/html/hypermall/sono
		file_server
	}
	log {
		output file /var/log/caddy/ica.json
		format json
	}
}

Note the rewrite directive and the change in the root.

Or, if you only want to show english.html or francais.html when the requested file doesn’t exist, you can use try_files:

aki.akhusono.com {
	import dynamic
	handle * {
		try_files {path} /english.html
		root /var/www/html/hypermall/sono
		file_server
	}
	log {
		output file /var/log/caddy/aki.json
		format json
	}
}
ica.akhusono.com {
	import dynamic
	handle * {
		try_files {path} /francais.html
		root /var/www/html/hypermall/sono
		file_server
	}
	log {
		output file /var/log/caddy/ica.json
		format json
	}
}

Again, take note of the try_files directive and updated root values.

3 Likes

Adding to the great responses by @timelordx, note that the root directive takes a path to a directory. You cannot point root at a file. You should use try_files or rewrite if you want to force requests to a file.

3 Likes

Hi Timelordx,

Great!

Thank you for the great support and documentation references.

You are right, the stratml folder should have an index.html file and I will use the try_files (or rewrite) for the others.

I will also further look into error handling.

Great stuff.

Thank you.

1 Like

Hi Mohammed90,

Indeed a great response by @timelordx.

Thank you for your support.