Proxy single port change to full URL

I had this configuration for port 8787
A.DNS.URL:8787 {
proxy / remote.dns.url:8787 {
tls off
log syslog
errors syslog
http://A.DNS.URL:8787 works!!
… and changed it to:
A.DNS.URL { #<== just remove the 8787 here
proxy / remote.dns.url:8787 {
tls off
log syslog
errors syslog
http://A.DNS.URL:8787 does not work!!
… and now I get this:
caddy: [INFO] A.DNS.URL - No such site at :80 (Remote: ip.remote.dns.url, Referer: )


Since you removed port 8787 from the site label, this is expected.

It looks like you tried to access it on port 80, but you haven’t configured Caddy to serve your site on port 80.

By default, without Automatic HTTPS, Caddy will serve your sites on port 2015. The assumption is that you’re probably doing local development, unless you enable Automatic HTTPS or manually specify the port.

No I didn’t try to access it on port 80. I tried to access it from A.DNS.URL, but proxy / A.DNS.URL:8787 should not try to access the remote.dns.url on port 80. Again all I did was remove the :8787 from the site to serve.

So, in chrome browser A.DNS.URL:8787, before change, and then after change in chrome browser A.DNS.URL (without :8787), Caddy from the upstream server tries for some reason to access A.DNS.URL on port 80, not as directed on 8787.


Port 80 is the default HTTP port. When you type a URL with no port, the browser uses that default, not whatever you used previously or what you defined in a Caddyfile.

You will always need to type the URL with port 8787, or the browser will keep defaulting to port 80.

Your browser does not show :80 in the address bar because it is not necessary to inform the end user that they’re on the default HTTP port; that information is not relevant to the vast majority of people. The browser will show the port if you’re using a non-standard one, though.

Correct, so caddy should serve this from the proxy directive from port 8787

That’s not the case. Since you removed the port from your site label in your Caddyfile, Caddy will serve it from Caddy’s default port (which is port 2015).

Caddy will not take the port specified in a proxy’s upstream server as an instruction on which port to serve its own site on. A port on an upstream server is just that - a port on an upstream server to proxy to.

No, it is a valid external url, it will not serve it on 2015. I have full DNS control.

That’s fine, but you’ve turned tls off, which makes the site ineligible for Automatic HTTPS.

That means that Caddy will not manage your certificates, will not host your site on port 80 and 443, and will not redirect visitors from HTTP to HTTPS.

Instead, it will use port 2015, unless you specify some other port.

correct, so it should talk from http://A.DNS.URL (port 80), and proxy to remote 8787.

It dosen’t.

That is not the case. You may review the documentation:

The default port is 2015 (unless the site qualifies for automatic HTTPS, in which case it’s changed to 443 for you). The scheme portion is another way to specify a port. Valid schemes are “http” or “https” which represent, respectively, ports 80 and 443. If both a scheme and port are specified, the port takes precedence.

If you want Caddy to serve your site on port 80 instead of port 2015, you must do one of the following:

  • Enable Automatic HTTPS
  • Specify the scheme http:// in your site label, which implies port 80
  • Specify the port explicitly as :80 in your site label

So, with TLS off, Caddy dosen’t default to http://?

That’s correct - Caddy doesn’t serve your site on the standard HTTP port if you disable Automatic HTTPS, unless you specifically configure it to do so.

(It does use the HTTP scheme, but on a non-standard port - 2015.)

TLS off, disables Automatic HTTPS, but does not revert to standard http on port 80, it serves on the non-standard port 2015. Ok, a little confusing. Thought TLS off do not serve on 443.

Thank you so much. I will make some changes, and always remember TLS off => port 2015!

1 Like

So, the error I was getting was Caddy saying there was nothing defined to serve on port 80! Makes sense now.

1 Like

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