Nginx config with proxy_cache

Hi,

I’ve been reading about nginx recently and I came across the proxy_cache directive that I haven’t seen in any of the nginx Meteor configs online. Is there a reason for that, or would it be a good idea to use it?

The config would look something like this:

proxy_cache_path /var/lib/nginx/cache levels=1:2 keys_zone=backcache:8m max_size=50m;
proxy_cache_key "$scheme$request_method$host$request_uri$is_args$args";
proxy_cache_valid 200 302 10m;
proxy_cache_valid 404 1m;

With the only thing to not cache being the route /?

Are there any security concerns using this cache such as caching users’ private data? How does the cache work with websockets?

Also, I’ve nginx configs that assume that the cached files are on the server running nginx already, but if the server is dedicated to only running nginx this doesn’t work, so is proxy_cache then the way to do this?

Caching with nginx is great, but it’s intended to help out with serving static files. Whether its use will make much of an impact in your environment really depends on the nature of your application, and how much static content your serving up. Check out nginx’s great 5 Performance Tips for Node.js Applications article, for a good explanation of how this works, and when it makes sense to use it.

1 Like

On this point, is there something in the Meteor guide or related ‘official’ documentation about how to reverse proxy with nginx when the app is on Galaxy? The https://galaxy.meteor.com/help/configuring-dns seems to be missing?

I use the reverse proxy for my other, non meteor services quite happily, and really like the idea of having nothing core facing the internet.

Thanks so much.

Tat

hey @tathagatbanerjee,

did you find any documentation? Or could you make it work by yourself?
Do you have a config file to share?
I am looking for a nginx setup and I’m not familiar with server setup at all…

This should get you started:

This is a more recent article:

And:
http://www.meteorpedia.com/read/nginx

And:

1 Like

not yet mate - sorry. I’m just about getting to here. If I work out something useful, I’ll post it here.

Tat