Caddyserver and Rancher

Hello my friends,

I want to setup Caddyserver to Rancher and already got it running, but I can’t proxy a domain to my WordPress Container.

  1. I get “Connection refused” when I try to curl the domain. I forwarded the port 80 and 443 to Caddy, so this can’t be the problem.
  2. I also tried to ping the internal DNS of the WordPress Container and I get the response from both sides.
  3. I also tried to curl localhost on the WordPress container and I get response (well its just did not find the database or something like that, but this does not matter now)

The weird thing is also that Caddyserver gives no logs? I entered the stuff on the Caddyfile, but no logs?

Here is my Caddyfile:

https://www.domain.com {
    log /var/log/access.log
    errors /var/log/error.log
    proxy / wordpress.domain.rancher.internal {
        transparent
    }
    tls self_signed
}
domain.com {
    redir / https://www.domain.com{uri}
}

I really would appreciate your help guys!

Best
René

Can you curl wordpress.domain.rancher.internal from the Caddy container?

Getting connection refused sounds interesting. Can you serve up static files, a basic hello world index.html perhaps?

Hello Matthew,

I cant curl from Caddy container, because there is no curl in the Caddy package.
Weird thing is that it dont create logfiles, which means it dont get requests? I have looked at traffic in rancher in the Caddy container and it gets a peak when I request the URL.

I will try to serve a static file directly from Caddy later this day, because I am currently in the office.

Thank you!

Hey Matthew,

I changed the Caddy package to abiosoft where I have curl. I can curl the WordPress container and get same response as curling localhost on the WordPress container.
I also tried to serve a markdown, but still having that connection refused.

I have no clue whats going on.

Thank you!

Changes:

I have tried another thing and got forward I think… now I get this in the log “docker logs containerid”:

2016/12/22 19:43:00 [INFO][squashfolio.de] Server responded with a certificate.
2016/12/22 19:43:00 [WARNING] Stapling OCSP: no OCSP stapling for [squashfolio.de]: ocsp: error from server: unauthorized
 done.
https://www.squashfolio.de
https://squashfolio.de
http://www.squashfolio.de
http://squashfolio.de
2016/12/22 19:43:03 [INFO] SIGTERM: Terminating process
Activating privacy features...2016/12/22 19:43:06 [WARNING] Stapling OCSP: no OCSP stapling for [squashfolio.de]: ocsp: error from server: unauthorized
 done.
http://www.squashfolio.de
http://squashfolio.de
https://www.squashfolio.de
https://squashfolio.de

Whats wrong?

To me, it sounds like requests aren’t reaching Caddy properly, which could be an issue with your configuration of Rancher, or perhaps your firewall.

If you can exec into your Caddy container, you could try something like installing Python and running python -m SimpleHTTPServer 80 to see if you can get a response from http://www.domain.com. If you still get Connection Refused, that way you know it’s not a Caddy issue.

Just saw your edit. Caddy’s log looks good. It even looks like it fetched a certificate, so it seems like LetsEncrypt was able to access it fine?

What do you get if you change your Caddyfile to something simple like :80 { browse } and navigate there via IP address?

When I curl the domain now I get the right response, just have to fix my database error now.

What do you mean by :80 { browse }?

Ahh, good to hear.

To try to reduce or eliminate issues with any of the other directives, including the proxy:

:80 {
    browse
}

Obviously unnecessary since you say it is now working as expected.

Thank you Matthew! Finally I got Caddy working… :blush: just have to fix the database error and I am good to go!

1 Like

Hey Matthew,

as I already mentioned I got Caddyserver running. The Database is working correctly now and moved the domain to point to my new server. Somehow I get just a clear Website, even when I curl the webseite I get zero response.

I have made a look into the Caddyserver logs and WordPress logs and I get the request, but no response. I also installed nginx as a container and served the nginx to Caddy to see if Caddy is proxying correctly. I get the welcome screen from nginx. So this is working fine, but when I again bind the WordPress container to Caddy its just nothing.

Do you have a clue what can be the reason to get no response on the client but requests on the server?

Thank you!

Not sure I’m afraid. Looks like Caddy’s doing its job properly and so is the Docker network driver, which points to the issue lying with your WordPress container. Can you set up a fresh, unmodified WordPress container to proxy to from Caddy and see if you get something out of that?

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