Cant able to optain certificate due to domain name contains invalid character

1. Caddy version (caddy version):

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

2. How I run Caddy:

caddy run

a. System environment:

Ubuntu 20.04 LTS

b. Command:

caddy run

c. Service/unit/compose file:

no

d. My complete Caddyfile or JSON config:

# The Caddyfile is an easy way to configure your Caddy web server.
#
# Unless the file starts with a global options block, the first
# uncommented line is always the address of your site.
#
# To use your own domain name (with automatic HTTPS), first make
# sure your domain's A/AAAA DNS records are properly pointed to
# this machine's public IP, then replace the line below with your
# domain name.
http://www.test1.ahluengineers.com{

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


http://www.test2.ahluengineers.com{
root * /var/www/ram2/html
}
# Enable the static file server.
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

# Refer to the Caddy docs for more information:
# https://caddyserver.com/docs/caddyfile

3. The problem I’m having:

i have 2 subdomains

  1. test1(dot)ahluengineers(dot)com
  2. test2(dot)ahluengineers(dot)com
    both pointing to a same digital ocean ip via amazon route 53
    both have different directories in www folder
    i am not able to run the website due to certification issue i think.

4. Error messages and/or full log output:

2020/05/18 13:34:53.495 INFO using adjacent Caddyfile
2020/05/18 13:34:53.497 INFO admin admin endpoint started {“address”: “tcp/localhost:2019”, “enforce_origin”: false, “origins”: [“localhost:2019”, “[::1]:2019”, “127.0.0.1:2019”]}
2020/05/18 13:34:53.497 INFO http server is listening only on the HTTP port, so no automatic HTTPS will be applied to this server{“server_name”: “srv0”, “http_port”: 80}
2020/05/18 13:34:53.497 INFO http server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS {“server_name”: “srv1”, “https_port”: 443}
2020/05/18 13:34:53.498 INFO http enabling automatic HTTP->HTTPS redirects {“server_name”: “srv1”}
2020/05/18 13:34:53.498 WARN http user server is listening on same interface as automatic HTTP->HTTPS redirects; user-configured routes might override these redirects {“server_name”: “srv0”, “interface”: “tcp/:80”}
2020/05/18 13:34:53.498 INFO tls cleaned up storage units
2020/05/18 13:34:53.499 INFO http enabling automatic TLS certificate management {“domains”: [“file_server”]}
2020/05/18 13:34:53.499 INFO autosaved config {“file”: “/root/.config/caddy/autosave.json”}
2020/05/18 13:34:53.499 INFO serving initial configuration
2020/05/18 13:34:53 [INFO][cache:0xc0006bae60] Started certificate maintenance routine
Successfully started Caddy (pid=4556) - Caddy is running in the background
2020/05/18 13:34:53 [INFO][file_server] Obtain certificate; acquiring lock…
2020/05/18 13:34:53 [INFO][file_server] Obtain: Lock acquired; proceeding…
root@ubuntu-s-1vcpu-1gb-blr1-01:/etc/caddy# 2020/05/18 13:34:54 [INFO][file_server] Waiting on rate limiter…
2020/05/18 13:34:54 [INFO][file_server] Done waiting
2020/05/18 13:34:54 [INFO] [file_server] acme: Obtaining bundled SAN certificate given a CSR
2020/05/18 13:34:55 [ERROR] acme: error: 400 :: POST :: https://acme-v02.api.letsencrypt.org/acme/new-order :: urn:ietf:params:acme:error:rejectedIdentifier :: Error creating new order :: Cannot issue for “file_server”: Domain name contains an invalid character, url: (challenge=tls-alpn-01 remaining=[http-01])
2020/05/18 13:34:57 [INFO] [file_server] acme: Obtaining bundled SAN certificate given a CSR
2020/05/18 13:34:57 [ERROR] acme: error: 400 :: POST :: https://acme-v02.api.letsencrypt.org/acme/new-order :: urn:ietf:params:acme:error:rejectedIdentifier :: Error creating new order :: Cannot issue for “file_server”: Domain name contains an invalid character, url: (challenge=http-01 remaining=[])
2020/05/18 13:34:59 [ERROR] attempt 1: [file_server] Obtain: [file_server] acme: error: 400 :: POST :: h ttps://acme-v02.api.letsencrypt.org/acme/new-order :: urn:ietf:params:acme:error:rejectedIdentifier :: Error creating new order :: Cannot issue for “file_server”: Domain name contains an invalid character, url: - retrying in 1m0s (6.131743096s/720h0m0s elapsed)…

5. What I already tried:

by seeing the logs i think it is happening due to test1 and test2 domain naming scheme
but i am not experienced to understand it deeply i tired searching over documentation i thought it is the problem with tls off and tls email so i tried that too it didnt worked

6. Links to relevant resources:

https://caddyserver.com/v1/docs/tls
doc of v1 caddy

Could you confirm if this appear in your domain name which is not tally with your problem?
www.test1.ahluengineers.com

2 Likes

You must put a space between your domain and {. Caddy is parsing your domain as including the brace.

Also, you can’t have file_server outside a site block, you’ll need to add that to each site block right after root.

2 Likes

thank you thank you you have mentioned my mistake. i was so tired by doing things i dont know. i cant submit 2 solutions :frowning: thank you

1 Like

thank you i was not knowing there should be space between domain and { thank you so much :slight_smile:

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