I posted this on the nginx mailing list but haven't heard back from anyone so I thought I'd give it a crack over here on stackoverflow :)
I currently have a Django app hosted up on Amazon EC2. All of my data is served through Gunicorn on port 8000 (a Python WSGI HTTP Server for UNIX. It's a pre-fork worker model ported from Ruby's Unicorn project). I don't have to worry about passing static content (images) to the client because all of that is handled for me by Amazon's S3 service. Django passes the url of the content through Gunicorn to the client via json. The client can then download it.
My Django app is hosted on a t1.micro instance. Here are the specs as provided by Amazon Web Services:
Processor: Up to 2 EC2 compute units (for short periodic bursts). Virtual cores: 1 Memory: 615 MiB Platform: 32-bit and 64-bit
I have 3 Gunicorn workers running alongside my Django app on this instance.
For my Nginx Reverse proxy server, I also use a t1.micro instance. I've set it up and everything is working perfectly fine. Here is my etc/nginx/sites-enabled/default config as follows:
# Gunicorn server
upstream django {
server 10.0.10.0:8000;
}
# Serve static files and redirect any other request to Gunicorn
server {
listen 80;
server_name 23.0.23.23/;
#root /var/www/domain.com/;
#access_log /var/log/nginx/domain.com.access.log;
#error_log /var/log/nginx/domain.com.error.log;
# Check if a file exists at /var/www/domain/ for the incoming request.
# If it doesn't proxy to Gunicorn/Django.
#try_files $uri @django;
# Setup named location for Django requests and handle proxy details
location @django {
proxy_pass http://django;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
This setup is great but it doesn't account for proxy buffering for slow clients. It also doesn't account for caching and it doesn't account for the number of nginx workers I will require. How can I configure the compression? I found resources that state there is something called gzip, does this support json? How can I fine tune my nginx config according to my t1.micro instance specs?
If you we're in my scenario, what settings would you use? Your answers and examples are much appreciated. Thank you :)