Somebody deploys caddy2 on AWS API gateway?

1. Caddy version (caddy version):

Caddy2 or Mercure HUB

Caddy was wrote on Golang, is posible to run it on aws api gateway?

Thanks in advance!.

Salvador.

I’m testing this now to replace our API Gateway.
initial config below:

testgw.hosted.com.au {
@testgw {
header X-Auth-Token *
}
reverse_proxy @testgw {
to api1.hosted.com.au:8080
header_up Host api1.hosted.com.au
}
log {
output file /var/log/caddy/testgw.log
}
}

one issue so far is that even if a request does not include the necessary header, the user still gets a 200 response

@packeteer that’s working as intended. You didn’t tell Caddy how to handle those other kinds of requests. So all Caddy can do is say “it worked as configured, here’s a 200 :man_shrugging:

You can use the respond directive to respond to those requests with an error status code if you prefer. You can also use the handle directive to implement fallback behaviour (only the first matching handle block will run)

1 Like

so I’m having a bit of a meltdown and cant figure this out…
I have a single domain and multiple subdirs to reverse proxy to backends. any tips would be much appreciated.

testgw.hosted.com.au {
@testgw {
header X-Auth-Token *
handle_path /sub1/* /sub2/*
}
reverse_proxy @testgw api1.hosted.com.au:8080
}

handle_path is a handler directive, not a request matcher. You probably want path, which is a matcher.

I’ver solved it with the following:

testgw.hosted.com.au {
handle_path /path1/v1/* {
reverse_proxy api1.hosted.com.au:8080
}
handle_path /path2/v1/* {
reverse_proxy api2.hosted.com.au:8080
}
}

oops, still not working. I think it’s because the hostname being sent to the backend is incorrect ?!?

Ok, I think I’ve got it now:

testgw.hosted.com.au {
handle_path /path1/v1/* {
request_header Host api1.hosted.com.au
reverse_proxy api1.hosted.com.au:8080
}
handle_path /path2/v1/* {
request_header Host api1.hosted.com.au
reverse_proxy api2.hosted.com.au:8080
}
}

now I just need to cater for reverse proxy to a subdir, which should be a simple rewrite

This topic was automatically closed after 30 days. New replies are no longer allowed.