Error Server Block without any key, line length?

1. The problem I’m having:

After setting up network and firewall, I installed Caddy and provided a Caddyfile I worked out here with your support. Caddy is giving a Server without any key is global configuration, and if used, it must be first. Server blocks all seem to have name(s). I may need help to pinpoint the issue.

I can run my Caddyfile in an application that obfuscated the site names and leaves everything else the same. The obfusticated version works fine with caddy and adapts to son.

But not the real Caddyfile.

Since some server blocks have many (up to 8) redirection names. The names in the real Caddyfile are longer than names in the “obfuscated” version. Could some server block names exceed a line length limit of some kind?

2. Error messages and/or full log output:

Error: Server block without any key is global configuration, and if used, it must be first. 

3. Caddy version:

v2.8.4

4. How I installed and ran Caddy:

I used the caddy-install.sh script

a. System environment:

Ubuntu 24.04 no docker.

b. Command:

caddy run
I just put the Caddyfile in the current directory

c. Service/unit/compose file:

na

d. My complete Caddy config:

{
	debug
	email webtek@hyperbase.com
}
(dynamic) {
	handle /xml/* {
		reverse_proxy localhost:3000
	}
}
(logging) {
	log {
		output file /var/www/log/caddy.log
		format json
	}
}
hyperbase.com www.hyperbase.com {
	import dynamic
	handle * {
		root /var/www/html/library/hyperbase/hyperbase/
		file_server
	}
	import logging
}
stratml.hyperbase.com {
	import dynamic
	handle * {
		root /var/www/html/library/hyperform/stratml/
		file_server
	}
	import logging
}
dnaos.com www.dnaos.com distributed.solutions www.distributed.solutions {
	import dynamic
	handle * {
		root /var/www/html/library/hyperlib/dnaos/
		file_server
	}
	import logging
}
01communications.com www.01communications.com 01communications.org www.01communications.org {
	import dynamic
	handle * {
		root /var/www/html/library/hyperlib/com01/
		file_server
	}
	import logging
}
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/library/hypermedia/c2/
		file_server
	}
	import logging
}
telepathmedia.com www.telepathmedia.com {
	import dynamic
	handle * {
		root /var/www/html/library/hypermedia/telepath/
		file_server
	}
	import logging
}
editionsconsonance.com www.editionsconsonance.com consonancepublishing.com www.consonancepublishing.com {
	import dynamic
	handle * {
		root /var/www/html/library/hypermall/consonance/
		file_server
	}
	import logging
}
accordeon101.com www.accordeon101.com accordion101.com www.accordion101.com {
	import dynamic
	handle * {
		root /var/www/html/library/hypermedia/accordeon/
		file_server
	}
	import logging
}
musicnovatory.com www.musicnovatory.com novatoire.com www.novatoire.com {
	import dynamic
	handle * {
		root /var/www/html/library/hypermedia/musnov/
		file_server
	}
	import logging
}
musicphenomenon.com www.musicphenomenon.com tunetuneup.com www.tunetuneup.com {
	import dynamic
	handle * {
		root /var/www/html/library/hypermedia/mup-en/
		file_server
	}
	import logging
}

{
	import dynamic
	handle * {
		root /var/www/html/library/hypermedia/mup-fr/
		file_server
	}
	import logging
}
grosbonchant.com www.grosbonchant.com {
	import dynamic
	handle * {
		root /var/www/html/library/hypermedia/gbc/
		file_server
	}
	import logging
}
knowledgearchitect.org www.knowledgearchitect.org knowledgesharing.solutions www.knowledgesharing.solutions {
	import dynamic
	handle * {
		root /var/www/html/library/hyperlib/ka/
		file_server
	}
	import logging
}
kebek.org www.kebek.org prosperite-solidarite.org www.prosperite-solidarite.org {
	import dynamic
	handle * {
		root /var/www/html/library/hyperform/kebek/
		file_server
	}
	import logging
}
prosperity-solidarity.org www.prosperity-solidarity.org {
	import dynamic
	handle * {
		root /var/www/html/library/hyperform/sps/
		file_server
	}
	import logging
}
andrecusson.com www.andrecusson.com {
	import dynamic
	handle * {
		root /var/www/html/library/hyperform/akhu/
		file_server
	}
	import logging
}
michelperrault.com www.michelperrault.com {
	import dynamic
	handle * {
		root /var/www/html/library/hypermall/pero/
		file_server
	}
	import logging
}
conradletendre.com www.conradletendre.com {
	import dynamic
	handle * {
		root /var/www/html/library/hypermall/letendre/
		file_server
	}
	import logging
}
jeanchatillon.com www.jeanchatillon.com {
	import dynamic
	handle * {
		root /var/www/html/library/hypermall/chatillon/
		file_server
	}
	import logging
}

5. Links to relevant resources:

The error message most likely refers to this section of your configuration. You’re missing the virtual names in front of the French MUP. I believe Caddy is treating it as a global server section, which you already have one.

2 Likes

HI timelordx,

Great.
I had missed it.

Thank you.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.