Caddy serve an ip address

1. The problem I’m having:

I’m trying to add a second website to be hosted by Caddy. It doesn’t matter if it’s by https or http.

The second website doesn’t have a domain, so I was hoping Caddy could serve the index.html at the ip address for the server.

The other website hosted by Caddy still works when I try to add the second website. It’s only the new website that doesn’t show in the browser.

I tried to add the second website by doing this in my caddyfile {
   root * /var/www/html2

2. Error messages and/or full log output:

When I enter the ip address in the browser it says `This site can’t provide a secure connection`

3. Caddy version:


4. How I installed and ran Caddy:

a. System environment:


b. Command:

Please use the preview pane to ensure it looks nice.

c. Service/unit/compose file:

Please use the preview pane to ensure it looks nice.

d. My complete Caddy config:


  servers {
} {
        # Set this path to your site's directory.
        root * /var/www/html

        # Enable the static file server.

        # Another common task is to set up a reverse proxy:
        # reverse_proxy localhost:8080

        # Or serve a PHP site through php-fpm:
        # php_fastcgi localhost:9000
} {
   root * /var/www/html2

5. Links to relevant resources:

Probably because you tried using https:// instead of http://.

Why aren’t you using a domain? You can use a subdomain of your existing domain, like or whatever.

I’m not using a domain because I don’t want to show the domain (the only one I have) to a potential client. I’d rather it be an ip address rather than the stupid domain name.

So you expect Caddy to be able to serve an ip address like this? {
   root * /var/www/html2

You can get more domains, e.g. free ones from DuckDNS or whatever. You’re not limited to only having one domain.

There’s no issue with serving from an IP host. You haven’t actually shown the evidence that it’s not working. Make a request with curl -v and show what you get.

I assumed i’d be able to reach the website through the IP address in the browser, and when I couldn’t, assumed that something was wrong with my Caddyfile.

When I curl my website curl, I get the index page for var/www/html, so I’d hope to see the index page for var/www/html2when I do curl or curl but I get nothing.

When I do curl -v, I get

* Trying


* Connected to ( port 80 (#0)

> GET / HTTP/1.1

> Host:

> User-Agent: curl/7.64.1

> Accept: */*


< HTTP/1.1 308 Permanent Redirect

< Connection: close

< Location:

< Server: Caddy

< Date: Wed, 20 Mar 2024 17:31:14 GMT

< Content-Length: 0


* Closing connection 0

Is that what you’d expect to see? I have no idea if it’s “working”.

Are you sure you reloaded Caddy after changing your config?

That behaviour from curl -v shows that Caddy responded with a redirect to HTTPS after seeing your request, which is the default behaviour when there’s no site.

Show your Caddy logs, please.

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