How do I Generate a Self-signed Certificate using a domain name?

1. The problem I’m having:

I don’t have a dns server available, so I appended a mapping to the hosts file for testing purposes.
like this:
192.168.89.51 test.mytestserver.dev
So I want to use caddy to generate a self-signed certificate for test.mytestserver.dev
But when I wrote the domain name in the caddyfile it applied for the publicly trusted certificate. for example through Let’s Encrypt.
But i want to generate by pki.ca.local…

I have seen in the documentation that tls internal is used.
But I don’t have a good understanding of it, and I might need an example that looks like my scenario.

thanks

2. Error messages and/or full log output:

no error, just a question of usage

3. Caddy version:

v2.6.4 h1:2hwYqiRwk1tf3VruhMpLcYTg+11fCdr8S3jhNAdnPy8=

4. How I installed and ran Caddy:

  • Use the official binary file
    Edit Caddyfile
    caddy run

a. System environment:

Centos7 x86_64

b. Command:

caddy run

c. Service/unit/compose file:

Did not use

d. My complete Caddy config:

192.168.89.51

reverse_proxy 127.0.0.1:8080

5. Links to relevant resources:

None

This is what you want:

test.mytestserver.dev {
	tls internal
	reverse_proxy 127.0.0.1:8080
}
1 Like

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