I am planning to move all my static content to a CDN so on my server I only have dynamic content left. I now have Nginx set up as reverse proxy to Apache. The static request tha
What I've done for one website is :
This without having to set up two domains : all is on the same domain.
Basically, what I've done is :
Here's how my nginx's configuration file looks like :
server {
listen 80;
server_name MY_DOMAIN_NAME;
access_log /var/log/nginx/MY_DOMAIN_NAME.access.log;
gzip on;
gzip_comp_level 2;
gzip_proxied any;
gzip_types text/plain text/html text/css text/xml application/xml application/xml+rss application/xml+atom text/javascript application/x-javascript application/javascript;
location ~* ^.+\.(jpg|jpeg|gif|png|ico)$ {
root /home/www/MY_DOMAIN_NAME;
#access_log off;
gzip off;
expires 1d;
}
location ~* ^.+\.(css|js)$ {
root /home/www/MY_DOMAIN_NAME;
#access_log off;
expires 1d;
}
location ~* ^.+\.(pdf|gz|bz2|exe|rar|zip|7z)$ {
root /home/www/MY_DOMAIN_NAME;
gzip off;
}
location / {
proxy_pass http://MY_DOMAIN_NAME:8080;
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;
proxy_max_temp_file_size 0;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
}
Now, why do such a thing ?
Well, nginx is supposed to :
So, I suppose it could help on a website with a bit of traffic, to lower the load that's put on Apache.