Did you try to start the server? Did it start up OK? Did you try to browse to it? Did you get a response? Did it not serve the files you expected to see?
A good way to ensure you get good help is by asking yourself and answering the following questions:
What did I do?
What result did I expect?
What did I get instead?
e.g. “I opened example.com:30000 in my browser. I expected to see the index.html I put in the web root. Instead, the browser showed a timeout error.”
Sorry to express unclearly. Here’s a detailed description:
I use another proxy server to transfer data from 433 to 127.0.0.1:30000, and I make nginx listen to port 127.0.0.1:30000 as a normal server. It worked smoothly, but if I tried to convert it to caddy, the browser showed a timeout error.
Thanks for your help!
Does the example.com domain in your Caddyfile have a DNS entry pointing it to your Caddy server?
Does your Caddy host have port 30000 unblocked?
A timeout generally means that your browser couldn’t reach Caddy at all; usually because it doesn’t know what the correct IP address is to find it, or because something (e.g. a firewall) was in the way.
Yes, I do transfer data from example.com:443 to 127.0.0.1:30000. With my nginx config, I could just visit example.com (use port 443), but don’t need to visit example.com:30000. I am just wondering if caddy could function as nginx’s “listen 127.0.0.1:30000”. Thanks!
Caddy can indeed do this, and the Caddyfile you already posted should be functional; it might need tweaking, but it should work.
The issue you’ve mentioned is a timeout in the browser. That heavily implies a networking issue - but it doesn’t make sense if you can access nginx normally on this port but not Caddy.
Yes, caddy works. I made a mistake, while I actually use systemd to run caddy; and I have done some tests to ensure it.
Is it probably because caddy’s “example:30000” is different from “127.0.0.1:30000”? Moreover, the timeout error might be because my firewall is open and only port 80 and 443 are allowed.
As for the firewall - if you’re connecting from the same host to itself, the firewall might not matter. If you’re proxying between two hosts, you might need to allow your reverse proxy to access Caddy’s port 30000 specifically.