Caddy basics - two sites

1. Caddy version (caddy version):

v2.0.0 h1:pQSaIJGFluFvu8KDGDODV8u4/QRED/OPyIR+MWYYse8=

2. How I run Caddy:

a. System environment:


b. Command:

caddy run -config Caddyfile

d. My complete Caddyfile or JSON config:

    http_port 8080
    https_port 8080

localhost:8080 {
    respond "site1"

localhost:9999 {
	respond "site2"

3. The problem I’m having:

I’m trying to run two sites through one server locally. I have added the http_port config in the global section, to deactivate SSL rereouting. I don’t know how to this for both sites.

4. Error messages and/or full log output:

$curl localhost:8080
$curl localhost:9999
"Client sent an HTTP request to an HTTPS server."

5. What I already tried:

I tried http_port 8080, 9999

6. Links to relevant resources:

I think you’ll want to use the auto_https global option which is available in the latest v2.1 beta released a few days ago:

You can download it from here:

Well, this can’t be right. Can’t have two separate listeners on the same port (i.e. one for HTTP and one for HTTPS). (That is, unless you’re using something like Conncept: It’ll definitely cause some problems if you keep it there and start trying to serve sites on default ports.

As @francislavoie stated, you can use the new global auto_https option in v2.1 to disable Automatic HTTPS entirely, which will have everything served as HTTP.

Alternately, you can specify the scheme in your site label, e.g. http://localhost:8080, http://localhost:9999. Then you can ditch the global port options entirely.

When the scheme is ambiguous (i.e. unspecified), Caddy will assume a site on any port that isn’t the HTTP port is in fact a HTTPS site, if it can.

1 Like

thanks a lot, that works

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