Coder Social home page Coder Social logo

Comments (17)

McPizza0 avatar McPizza0 commented on August 26, 2024 2

Sounds a bit like a GPT

Re-read the issue again, that is how the config file was
the issue is not there
test it yourself

from random.

McPizza0 avatar McPizza0 commented on August 26, 2024 1

its easy enough to replicate the setup
dont need a meeting for that

im not looking for "technical support" and diagnosis, i need a solution that works

from random.

McPizza0 avatar McPizza0 commented on August 26, 2024 1

Thanks for trying @ezhil56x and @TheVixhal

closing this issue and removing the bounty
already spent 6 hours on this

will build out something better in less time: https://github.com/uninbox/webhook-proxy

from random.

algora-pbc avatar algora-pbc commented on August 26, 2024

💎 $25 bounty created by McPizza0
🙋 If you start working on this, comment /attempt #1 along with your implementation plan
👉 To claim this bounty, submit a pull request that includes the text /claim #1 somewhere in its body
📝 Before proceeding, please make sure you can receive payouts in your country
💵 Payment arrives in your account 2-5 days after the bounty is rewarded
💯 You keep 100% of the bounty award
🙏 Thank you for contributing to McPizza0/random!

👉 Add a bountyShare on socials

Attempt Started (GMT+0) Solution
🟢 @TheVixhal Feb 17, 2024, 7:48:50 AM WIP

from random.

McPizza0 avatar McPizza0 commented on August 26, 2024

conditions for bounty:

you must provide a working config via PR and explain how it works/what needs to be set up
if you're using cloudflare tunnels, you need to provide details config
if using caddy, provide detailed config

put configs in a pr, I will test, if it works, bounty is yours

from random.

TheVixhal avatar TheVixhal commented on August 26, 2024

/attempt #1

from random.

McPizza0 avatar McPizza0 commented on August 26, 2024

the caddy server lives in a vps, not on my local machine, can you clarify how @Local would help?

have you tried this config with a cloudflare tunnel?

the Caddy config was fine, forwarding requests to the cloudflare tunnel
but somewhere between them, there were some issues with too many redirects

https://tunneladdress.mydomain.dev/ will be a cloudflare tunnel into my local system

from random.

TheVixhal avatar TheVixhal commented on August 26, 2024

#1

Thank you for the clarification. If CaddyServer is running on a VPS, the @Local matcher wouldn't be applicable because it's designed to identify requests originating from localhost, which would be the local machine where CaddyServer isn't running in this case.

For your scenario with Cloudflare Tunnel and CaddyServer on a VPS, you can simplify the configuration to directly proxy requests to the Cloudflare Tunnel address and the failover server.

proxy.mydomain.dev {
    reverse_proxy {
        to https://tunnelAddress.mydomain.dev
        to https://failover.mydomain.dev
    }
}

This configuration file instructs CaddyServer to proxy all incoming requests to either https://tunnelAddress.mydomain.dev or https://failover.mydomain.dev based on their availability and health.

Please replace proxy.mydomain.dev, https://tunnelAddress.mydomain.dev, and https://failover.mydomain.dev with your actual domain and addresses respectively.

Once you've updated the configuration file, save it as Caddyfile in your CaddyServer's configuration directory. Then, restart CaddyServer for the changes to take effect.

from random.

TheVixhal avatar TheVixhal commented on August 26, 2024

Re-read the issue again, that is how the config file was
the issue is not there
test it yourself

share your cadyserver logs.

from random.

ezhil56x avatar ezhil56x commented on August 26, 2024

@McPizza0

  • You are running an application on your VPS which is accessible through abc.123.com. And when you are running the same on your local machine you need abc.123.com to point to your local machine. Is this the expected behaviour?
  • And do you have a Static IP or want to make it public with Cloudflare tunnel?
  • Is the Caddy server and the application running on same VPS?

from random.

McPizza0 avatar McPizza0 commented on August 26, 2024

@ezhil56x

  • I am running a service online on VPS A which is accessible through service.123.com
  • I also occasionally run the same service locally on my machine, which is accessible online at local.123.com through a cloudflare tunnel
  • Caddy is running on a different vps online, through caddy.123.com

I want to be able send webhook messages to caddy.123.com and if I am online, it forwards them to local.123.com, if I am offline it forwards them to service.123.com

from random.

ezhil56x avatar ezhil56x commented on August 26, 2024

@McPizza0

Thanks for the info. It would be easier to troubleshoot if we could schedule an online meet

from random.

TheVixhal avatar TheVixhal commented on August 26, 2024

@ezhil56x

  • I am running a service online on VPS A which is accessible through service.123.com
  • I also occasionally run the same service locally on my machine, which is accessible online at local.123.com through a cloudflare tunnel
  • Caddy is running on a different vps online, through caddy.123.com

I want to be able send webhook messages to caddy.123.com and if I am online, it forwards them to local.123.com, if I am offline it forwards them to service.123.com

caddy.123.com {

    # Define a route for handling errors
    handle_errors {
    
        # Define a condition for when to trigger this route
        @offline {
            expression {http.error.status_code} == 502 # 502 Bad Gateway
        }
        
        # Proxy requests to service.123.com when offline
        reverse_proxy @offline https://service.123.com
    }

    # Define a route for normal operation
    reverse_proxy https://local.123.com {
    
        # Set the Host header to the upstream host
        header_up Host {http.reverse_proxy.upstream.hostport}
    }
}

Replace caddy.123.com, local.123.com, and service.123.com with your actual domain names.

from random.

McPizza0 avatar McPizza0 commented on August 26, 2024

@TheVixhal
in theory, should work great, nice directive with the handle_errors

In practice, it dosnt work
when the tunnel is down, initially it gives a 504, but the proxy condition didnt work
then it switched to a different error
image

so it seems that the tunnel always responds with something

this may not be viable after all
would need to add a way for it to check if the host is up by hitting a /health endpoint and only forwarding if it gets back a 200 code

from random.

francislavoie avatar francislavoie commented on August 26, 2024

The answer is in the docs: https://caddyserver.com/docs/caddyfile/directives/reverse_proxy#https

from random.

francislavoie avatar francislavoie commented on August 26, 2024

@TheVixhal stop using ChatGPT. That config is complete nonsense.

Source: I'm a Caddy maintainer. I wrote most of the Caddyfile docs.

from random.

TheVixhal avatar TheVixhal commented on August 26, 2024

@TheVixhal stop using ChatGPT. That config is complete nonsense.

Source: I'm a Caddy maintainer. I wrote most of the Caddyfile docs.

Sorry 😔😔😐

from random.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.