Hacker News new | ask | show | jobs
by gardentheory 5261 days ago
Why nginx AND varnish? I thought varnish could proxy as well? Or maybe could you explain your setup.
3 comments

Varnish is just a proxy, or webcache, as I believe they like to call it. Nginx is needed because Varnish won't talk directly to the uwsgi processes, Varnish only understands http. The data that Varnish need to cache has to be supplied by a webserver somewhere and nginx is pretty nice and easily configurable. So I would assume that the idea is to use nginx as the webserver, not the cache/proxy.
you can directly link uWSGI with varnish using http protocol instead of the uwsgi one: http://projects.unbit.it/uwsgi/wiki/Example#varnish
I did not know that... That's pretty awesome.
nginx is a much weaker proxy and doesn't allow as much customization as Varnish does. A coworker also ran into some basic HTTP compliance issues with nginx's cache and Vary headers - IIRC it simply ignores them outright. If you need more than very basic caching it's usually better to use Varnish because it's obsessively focused on doing that job well.

Depending on how you choose to implement it, this may also result in cleaner architecture if you have Varnish as a simple HTTP brick with little knowledge of the backend implementation, leaving all of the gory details to nginx.

I basically use nginx the way people would use Apache and Varnish I use as a webcache. Others have explained it thoroughly.