See this for installation instructions and Cloudflare varnish config:
See this for actual Varnish 4.0 config with Mediawiki:
Notice that if you're using SSL, Varnish isn't able to process SSL encrypted data. However, Nginx can function both as the PHP-FPM backend of varnish and an SSL decrypting frontend to varnish.
See the guide below to redirect Varnish HTTP to HTTPS.