Proxy : 404 Not Found


I try to access the backend servers via proxy.
I start three caddy servers as follow :

  • server0 : localhost:2000
  • server1 : localhost:2001
  • server2 : localhost:2002

The server0’s Caddyfile is :

localhost:2000 {
tls off
errors visible

proxy /blog localhost:2002
proxy / localhost:2001

log ./access.log


when access http://localhost:2000 via chrome, it’s correct.
but access http://localhost:2000/blog, it returns “404 Not Found”

I tried this on both caddy 0.9 and 0.9.1, it plays in the same way.

Is there anything wrong with the config?

thanks for your help in advance.

What happens if you try to access http://localhost:2002 in your web browser?

both work fine when i access the website via localhost:2001 or localhost:2002.

In fact, when i access via proxy,
only proxy / the-site-url works,
all other proxy /xxx the-site-url FAILED.

Perhaps you meant to use the without option for proxy.


proxy /blog localhost:2002 {
	without /blog

This may break other resources on the page however, if they are not referenced relative to the page.

I have tried this, always returns 404, :frowning:

Anybody know WHY?

Can you verify access log in the other servers and see if the requests are proxied to them. It may be the proxy returning 404, not server0.

thanks for your concern. @abiosoft

the access log tells that it is the server2(port 2002) who return the 404.

here is the access log :

  • server0 (port 2000) : ::1 - [25/Aug/2016:11:50:16 +0800] "GET /blog HTTP/1.1" 404 38
  • server2 (port 2002) : ::1 - [25/Aug/2016:11:50:16 +0800] "GET /blog HTTP/1.1" 404 38

Can you share server2’s Caddyfile ?

sure, here it is :

localhost:2002 {
	tls off
	errors visible
	root /Users/HANK/www/blog/public

	log ./access-blog.log

So, what do you expect it to respond with ?

Looks like this is what you need.

proxy /blog localhost:2002 {
	without /blog

What paths in server2 are valid ?

yes, it works!

I misunderstand the without parameter.

thank you very much, @abiosoft

1 Like

sorry for my misunderstand the without parameter. your answer is right, thank you!

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