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

VPP returns 200 even if a purge failed #3

Open
GabrSaac opened this issue Jun 16, 2016 · 1 comment
Open

VPP returns 200 even if a purge failed #3

GabrSaac opened this issue Jun 16, 2016 · 1 comment

Comments

@GabrSaac
Copy link

GabrSaac commented Jun 16, 2016

The solution should just be to check the status code of the response.

 response.StatusCode != 200

In your code:

response, err := varnishClient.Do(receivedReqCopy)
        if err != nil || response.StatusCode != 200 {

            log.Printf("%v%v Error sending request. Error: %v, Response: %+v\n", SERVICE_ID, LOG_FAIL, err, response)
            if *debug {
                log.Printf("%v For URL: %v\n", SERVICE_ID, receivedReqCopy.URL)
            }

            // discard and close response body

            respConcoChannel <- 500
            return
        }

@GabrSaac
Copy link
Author

GabrSaac commented Jun 16, 2016

See for instance https://www.varnish-cache.org/docs/trunk/users-guide/purging.html

        if (req.method == "PURGE") {
                if (!client.ip ~ purge) {
                        return(synth(405,"Not allowed."));
                }
                return (purge);
        }
        ...
        if (req.method == "PURGE") {
            if (client.ip !~ purge) {
              return(synth(403, "Not allowed"));
            }
            ban("obj.http.url ~ " + req.url); # Assumes req.url is a regex. This might be a bit too simple
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant