Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Caddy and Buffalo #1668

Open
MostHated opened this issue May 14, 2019 · 0 comments

Comments

Projects
None yet
1 participant
@MostHated
Copy link

commented May 14, 2019

Hello,
I am trying to simply get Caddy to point to my Buffalo app in Docker but can't seem to make that happen. I am hoping someone familiar with Caddy might have some insight?

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.

My Buffalo app 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:

version: "3"
services:
  rudp_blog:
    image: rudp_blog:latest #--- created using docker-compose build on my local machine to make an image from the Buffalo Dockerfile that was generated with my app
    container_name: rudp_blog
    depends_on:
      - mysql
    restart: "no"
    environment:
      - PORT=4569
      - ADDR=127.0.0.1 #---- Tried using 127.0.0.1 and 0.0.0.0
    ports:
      - 4569:4569
    networks:
      - rudp-mysql
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.