Unable to connect using server IP Address

Hello, I’m using Caddy v2 B12 and I was wondering if it was normal for the server to not respond to IP Direct requests?
I can get to my Website using DomainName.com but unable to using the ip address 123.10.10.123.com

Do I have to add the IP in my caddyfile as well?
123.10.10.123.cc:80 {
root * /www/
file_server
}

123.10.10.123.com is not an IP address.

IP addresses never have TLDs (Top-Level Domains, like .com or .cc) at the end.

Remove the .cc from your config and it should work.

123.10.10.123:80 {
    root * /www/
    file_server
}

Sorry, that’s what I meant, I didn’t mean to include the .cc :slight_smile: so I do have to include the IP address in my ‘caddyfile’ as well as Domain name if I want both to resolve to my web server from the Internet. Okay, thx

You could just listen on 0.0.0.0 which means “anything”. By omitting the IP entirely, that’s what it uses by default. So you can do this:

:80 {
    ...
}

That way, as long as ports are forwarded and your firewall allows connections on port 80, it should work.

Okay, thanks, I’ll give it a go.
Instead of having a separate section for 80 and 443 can I just combine the two?
:80 :443 {
root * /www/
file_server
}

1 Like

Yep! Although they’re comma separated.

See here for the docs: Caddyfile Concepts — Caddy Documentation

1 Like

Fun fact, I don’t think they actually have to be comma-separated unless you want to put the next address on a different line.

But in order to try to keep Caddyfiles more consistent, I’m not documenting that… for now. :stuck_out_tongue:

1 Like

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