Hello,
I am trying to simply get Caddy to point to internally hosted applications in Docker but they don’t end up working.
At first I kept getting back a 502 error, just to rule out using a .dev domain as being part of the issue I used a .com (both hosted on Cloudflare) but neither worked.
One application is made in Go Buffalo and running in a docker container, and is on port 4569
The other is just a standard phpmyadmin container running on port 4570
I can get to both just fine if I do 123.123.123.123:4569 or 123.123.123.123:4570 (using my real ip, of course)
I have tried everything I can find when it comes to my Caddyfile. Here are a few examples.
First I just had a very basic setup:
mydomain.dev:80 {
proxy / localhost:4569 {
transparent
}
}
I then tried:
mydomain.dev:80 { # <---- I tried with and without a port, as well as *.domain.dev:80, domain.dev:80 and a few other variations of things I found examples of
proxy / localhost:4569 {
transparent
websocket
}
}
I tried changing some things around such as
mydomain.dev:80, mydomain.dev:443 {
proxy / 127.0.0.1:4569 { #(here I also tried http://localhost:4569, http://127.0.0.1:4569, 0.0.0.0:4569, etc )
transparent
websocket
}
}
Where I currently am after scouring the web for more examples to try is this, which of course still doesn’t seem to work properly:
mydomain.com:80 {
root /srv/mydomain.com #( <---- this part works at the root of the domain to server normal files)
browse
gzip
tls mydomain.com {
dns cloudflare
}
proxy /blog http://127.0.0.1:4569 { #( <---- this part and the one below still do not work though)
header_upstream X-Forwarded-Host {host}:4569
header_upstream -Origin
header_upstream -Referer
websocket
transparent
}
proxy /admin localhost:4570 {
header_upstream X-Forwarded-Host {host}:4570
header_upstream -Origin
header_upstream -Referer
websocket
transparent
}
log /srv/mydomain.com/logs/access.log {
rotate_size 1
rotate_age 7
rotate_keep 2
}
errors /srv/mydomain.com/logs/error.log {
rotate_size 1
rotate_age 7
rotate_keep 2
}
}
Going to the root of the domain works, which I setup just to make sure it was doing anything at all, so I can view the file browser and a test text file I put in there. /blog is my go application, /admin is phpmyadmin. Neither work though, with or without the header_upstream stuff. I simply added those in because I came across them on a forum post and figured it was worth a try. I know I had something similar in my nginx configs on another server in which these worked, so I thought it might have been necessary.
More recently I have tried it with all of these different options with no success: (not all at once, of course)
proxy / localhost:4569 {
transparent
# fail_timeout 0s
# header_upstream Host {host}
# header_upstream X-Real-IP {remote}
# header_upstream X-Forwarded-Ssl on
# header_upstream X-Forwarded-Proto {scheme}
# header_upstream X-Forwarded-Host {host}:4569
# proxy_header Host {host}
# proxy_header X-Real-IP {remote}
# proxy_header X-Forwarded-Proto {scheme}
# proxy_header X-Forwarded-For {remote}
# websocket
# header_upstream -Origin
# header_upstream -Referer
# transparent
}
With my current test of simply:
domain.dev {
tls {
dns cloudflare
}
proxy / localhost:4569 {
transparent
}
}
It doesn’t come back with an actual 502 error this time, but it does seem to just loop over and over until eventually saying:
The page isn’t redirecting properly
An error occurred during a connection to domain.dev.
This problem can sometimes be caused by disabling or refusing to accept cookies.
So, possible progress I suppose.
If anyone has any suggestions, I would definitely love to hear them!
Thanks,
-MH