Welcome! Log In Create A New Profile

Advanced

Where to specify gzip and buffer parameters on nginx proxy and nginx web server?

Posted by fcukinyahoo 
Where to specify gzip and buffer parameters on nginx proxy and nginx web server?
November 03, 2014 11:36PM
I have setup nginx as reverse proxy which gets all 80 requests and proxies them to other appropriate web servers behind. One of those web servers is also nginx serving php site. I want to specify gzip, buffer, and caching options but I am not sure on which server's nginx.conf to specify them. On the proxy or web server or both. The options that i want to specify is below.

# Compression
gzip on;
gzip_comp_level 2;
gzip_min_length 1000;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain application/x-javascript text/xml text/css application/xml;

# Buffers
client_body_buffer_size 10K;
client_header_buffer_size 1k;
client_max_body_size 8m;
large_client_header_buffers 2 1k;

# Caching Static Files
location ~* .(jpg|jpeg|png|gif|ico|css|js)$ {
expires 365d;
}
On which server's configuration file do I specify these? On the nginx proxy or on web server or both?
Re: Where to specify gzip and buffer parameters on nginx proxy and nginx web server?
November 04, 2014 04:08AM
On the proxy, considering the speed between both nginx's being LAN speed.

---
nginx for Windows http://nginx-win.ecsds.eu/
so do i specify below in proxy nginx.conf in server section?

# Caching Static Files
location ~* .(jpg|jpeg|png|gif|ico|css|js)$ {
expires 365d;
}
Re: Where to specify gzip and buffer parameters on nginx proxy and nginx web server?
November 05, 2014 03:44AM
If thats where you want this to happen then yes.

---
nginx for Windows http://nginx-win.ecsds.eu/
i really dont care where it happens since both of the servers more than capable handling it. However, I have tried above Caching both on proxy and web server but in both cases I had all images missing. I think i m missing something somewhere.
Re: Where to specify gzip and buffer parameters on nginx proxy and nginx web server?
November 06, 2014 04:15AM
You only use it at one point not both, the frontend is the best point.

---
nginx for Windows http://nginx-win.ecsds.eu/
ok, got the buffers and gzip on the proxy level. I wanted to do caching on actual web server level. I have specified following in 'http' section;

proxy_cache_path /var/cache/www levels=1:2 keys_zone=devserv_cache:8m max_size=1000m inactive=600m;

and below in 'server' section,

# This block will catch static file requests, such as images, css, js
# The ?: prefix is a 'non-capturing' mark, meaning we do not require
# the pattern to be captured into $1 which should help improve performance
location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
# Some basic cache-control for static files to be sent to the browser
expires max;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";

According to the documentation on nginx wiki, I should see cached files hashes populating in '/var/cache/www' however, that folder is empty. Checked permissions for the folder, looking good.

Where should I look?
Re: Where to specify gzip and buffer parameters on nginx proxy and nginx web server?
November 07, 2014 04:33AM
Within location you forgot something like this:

fastcgi_cache_key $scheme$host$request_method$request_uri;
fastcgi_cache_valid 200 302 304 30m;
fastcgi_cache_valid 301 1h;
fastcgi_cache_valid any 5m;
fastcgi_cache_use_stale error timeout invalid_header updating http_500;

---
nginx for Windows http://nginx-win.ecsds.eu/
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 115
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready