Restart caddy and do reverse proxy same domain different ports

Hi all,

When I stop caddy I get all the time that the admin por is not available, and I 'm not sure if its reloading the config since the admin API is down.

A second problem I have is that I can’t find any example about create a reverse proxy with different ports on the same domain.

is it like this

my_domain {
reverse_proxy :exposed port localhost:port
reverse_proxy :otherexposed port localhost:port2
}

Do I have to do this with handlers only ?

Thanks in advance.

Josep

Please fill out the help topic template.

Click on “New Topic”, make sure the “Help” category is chosen, then copy the template that’s filled in the text box, and fill it out as a reply in this topic.

1 Like

Ok will do

1 Like

1. Caddy version (caddy version):

version 2.4.5

2. How I run Caddy:

caddy run or caddy start

a. System environment:

Linux 20.4

b. Command:

caddy run

c. Service/unit/compose file:


d. My complete Caddyfile or JSON config:

my_domain {
reverse_proxy :exposed port localhost:port
reverse_proxy :otherexposed port localhost:port2
}

3. The problem I’m having:

How can I run a reverse proxy that maps multiple ports on the same domain ?

4. Error messages and/or full log output:

No error not working.

5. What I already tried:

I tried with multiple configs no one worked

6. Links to relevant resources:

If I understand what you’re saying (your Caddyfile example is confusing because you’re not actually using numbers), then you might want something like this?

example.com:8000 {
	reverse_proxy localhost:8001
}

example.com:9000 {
	reverse_proxy localhost:9001
}

But doing this, you’re running on non-standard ports. What you should do instead is use a subdomain for each service, like this:

first.example.com {
	reverse_proxy localhost:8001
}

second.example.com {
	reverse_proxy localhost:9001
}

This way, you’ll be using the standard HTTPS port 443, and the routing will be by subdomain.

3 Likes

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