• Resolved bsteinlo

    (@bsteinlo)


    I recently installed Varnish on nginx for caching and it resulted as all contact submissions being flagged as spam and not going through. I even tried to disable my contact page from being cached, but this still didn’t work. In doing some research, I am thinking it’s maybe a conflict with nonce in CF7 and the caching layer. Do you have any suggestions on how to fix this?

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • shawnpyle

    (@shawnpyle)

    I recently setup a varnish cache in front of my wordpress instance based heavily on https://gist.github.com/matthewjackowski/062be03b41a68edbadfc. There was a unset req.http.User-Agent; line that was removing the user agent on the contact form post and since the determination of spam uses the user agent it was always returning spam.

    I initially thought it was a nonce issue as well. Disabling the nonce with the following in my wp-config.php, did not help.

    if ( !defined('WPCF7_VERIFY_NONCE') ) {
    	define('WPCF7_VERIFY_NONCE', false);
    }
    Thread Starter bsteinlo

    (@bsteinlo)

    @shawnpyle this is exactly what I found out as well! Thank you for the follow up and pointing to the determination of spam for user agent, very helpful. All is working for me now.

    I was wondering, what your cache time limits are? Is the nonce still an issue with this resolved? I originally had Varnish set to a 1 week of cache, but after reading (and thinking) that this was a nonce issue, I turned it down to 12 hours. Let me know your thoughts, thanks again!

    shawnpyle

    (@shawnpyle)

    The cache limits should be a function of how much your content changes. Ours doesn’t change much so we have it pretty long, like a week. I flush the entire cache when there are changes to any page because I don’t really know how to mark specific pages dirty (or didn’t care!).

    I’m also using docker containers for these services (caddy for http/s, varnish for caching, wordpress) so purging varnish wasn’t straight forward.

    Shawn

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Varnish Cache causes spam filter’ is closed to new replies.