Welcome! Log In Create A New Profile

Advanced

Re: Serving Static Files

September 27, 2009 11:52PM
Igor Sysoev Wrote:
-------------------------------------------------------
> On Fri, Sep 25, 2009 at 05:19:13AM -0400,
> bernard.barbosa wrote:
>
> > Sorry I am getting an error:
> >
> > "unknown directive "proxy_cache_path" in
> /usr/local/nginx/conf/nginx.conf:57
> > 2009/09/25 20:09:51 11656#0: the configuration
> file /usr/local/nginx/conf/nginx.conf test failed"
> >
> > I am using nginx version: 0.6.35 . Can you
> please help me?
>
> The HTTP cache has been introduced in 0.7.x. You
> should use 0.7.62.
>
>
> --
> Igor Sysoev
> http://sysoev.ru/en/

Hi Igor,

I have upgraded my nginx to version 0.7.62 and there is no error now thanks.
But i think it is not working as i expected it to be. With the configuration you gave me I can't find any activities on logs showing any connection or request on both server. Can you please check what seems to be wrong on my configuration?

These are the configurations:

On sample.server.com:
-----------------------------------------------------------------------------------------------------------------------------
user www-data www-data;
worker_processes 1;
# [ debug | info | notice | warn | error | crit ]
error_log /usr/local/nginx/logs/error.log info;
pid /usr/local/nginx/logs/nginx.pid;

events {
worker_connections 1024;
# use [ kqueue | rtsig | epoll | /dev/poll | select | poll ] ;
# check: http://wiki.nginx.org/NginxOptimizations
use epoll;
}

http {
include /usr/local/nginx/conf/mime.types;
include /usr/local/nginx/conf/fastcgi_params;

#
# logging
#
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $status '
'"$request" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /usr/local/nginx/logs/access.log main;

#
# other
#
sendfile on;
tcp_nopush on;
server_tokens off;
server_names_hash_bucket_size 128;

#
# timeouts
#
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
keepalive_timeout 10;

#
# gzip
#
gzip on;
gzip_buffers 16 8k;
gzip_comp_level 2;
gzip_proxied any;
gzip_vary on;
gzip_types text/plain text/css text/javascript application/x-javascript text/xml application/xml application/xml+rss;

proxy_cache_path /home/site/cache levels=1:2 keys_zone=STATIC:10m inactive=1h;

server {
listen 80;
server_name sample.server.com;

root /home/site/sample;
index index.php;

location /static/ {
proxy_pass http://sample.static.com;
proxy_cache STATIC;
proxy_cache_valid 1d;
proxy_cache_use_stale error timeout invalid_header updating;
}

if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?q=$1 last;
}

error_page 404 index.php;

# hide protected files
location ~* \.(engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template)$ {
deny all;
}

# hide backup_migrate files
location ~* ^/files/backup_migrate {
deny all;
}

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/site/sample$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
}
}

}
---------------------------------------

While on sample.static.com:
-----------------------------------------------------------------------------------------------------------------------------
#user nobody;
user www-data www-data;
worker_processes 1;
# [ debug | info | notice | warn | error | crit ]
error_log /usr/local/nginx/logs/error.log info;
pid /usr/local/nginx/logs/nginx.pid;

events {
worker_connections 1024;
use epoll;
}

http {
include /usr/local/nginx/conf/mime.types;
include /usr/local/nginx/conf/fastcgi_params;

default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $status '
'"$request" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /usr/local/nginx/logs/access.log main;

sendfile on;
tcp_nopush on;
server_tokens off;
server_names_hash_bucket_size 128;

#
# timeouts
#
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
keepalive_timeout 10;


#
# gzip
#
gzip on;
gzip_buffers 16 8k;
gzip_comp_level 2;
gzip_proxied any;
gzip_types text/plain text/css application/x-javascript
text/xml application/xml application/xml+rss text/javascript;

#
# Allows directory listing
#
autoindex on;

server {
listen 80;
server_name sample.static.com;
root /home/site/staticfiles;
index index.php;


# PHP files
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
}

# redirect server error pages to the static page /50x.html
#
error_page 404 index.php;
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# root html;
# }

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/site/staticfiles$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
}
}
}
------------------------------------------------
Subject Author Posted

Serving Static Files

vanderkerkoff June 08, 2009 05:32AM

Re: Serving Static Files

bernard.barbosa September 24, 2009 03:43AM

Re: Serving Static Files

Igor Sysoev September 24, 2009 06:12AM

Re: Serving Static Files

bernard.barbosa September 25, 2009 02:30AM

Re: Serving Static Files

Igor Sysoev September 25, 2009 04:58AM

Re: Serving Static Files

bernard.barbosa September 25, 2009 05:12AM

Re: Serving Static Files

bernard.barbosa September 25, 2009 05:19AM

Re: Serving Static Files

Igor Sysoev September 25, 2009 05:30AM

Re: Serving Static Files

Igor Sysoev September 25, 2009 05:34AM

Re: Serving Static Files

bernard.barbosa September 27, 2009 11:52PM

Re: Serving Static Files

bernard.barbosa September 27, 2009 11:54PM

Re: Serving Static Files

bernard.barbosa September 29, 2009 05:11AM

Re: Serving Static Files

bernard.barbosa October 04, 2009 11:08PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 160
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready