Arlo Carreon
Arlo Carreon

Reputation: 441

What is the best way to debug a VCL file?

I am writing inline C in my VCL file. More specifically I am using Maxmind's GeoIP database to geocode a visitor's IP. I have everything installed, I have followed all the wiki examples for GeoIP database and everything works swimmingly.

I am trying to now do some magic with GeoIP besides the return country examples. I want to return the visitor's city using the method GeoIP_record_by_addr(), which returns a pointer.

Problem: I cannot seem to correctly cast a GeoIPRecord* to char*. I have tried for hours. I get Varnish to compile my VCL file without any errors or notices, but the varnish server responds with 403.

Question: Anyway I can debug either the inline C or the 403 varnish is responding with?

Upvotes: 2

Views: 2509

Answers (1)

Gauthier Delacroix
Gauthier Delacroix

Reputation: 709

Generally, Firebug and varnishlog will be your best friends.

If you want to debug pure VCL, the best way is to send data into HTTP headers ([req/bereq/beresp/resp].http.[header name]) and check their value into Firebug (or varnishlog if you have few requests).

If you want to debug inline C, you can also play with headers (VRT_SetHdr()) but if your C code makes varnish crash, you'll see why into /var/log/messages.

You can also check varnishlog to see if varnish crashes...but when varnish crashes, you get timeouts, not 403...

I'd have to see your VCL to understand why you get 403 but technically, it's not an "error", but a "status", meaning that your request has been processed by varnish (and, unfortunately, forbidden somewhrere).

I don't think Varnish would return 403 except if you ask him to do it. So there's a big chance the 403 status comes from your web server (backend).

Anyway, your varnish doesn't seem to crash but rather have behavior issues.

Upvotes: 4

Related Questions