Serving Static Files
Igor Sysoev
is at rambler-co.ru
Fri Sep 25 13:23:47 MSD 2009
On Fri, Sep 25, 2009 at 05:12:30AM -0400, bernard.barbosa wrote:
> Igor Sysoev Wrote:
> -------------------------------------------------------
> > On Fri, Sep 25, 2009 at 02:30:32AM -0400,
> > bernard.barbosa wrote:
> >
> > > Hi Igor,
> > >
> > > Im sorry im a bit lost with the question and i
> > have no idea which is the best. Is it by proxying
> > or caching? I think yes they can change in the
> > future..
> > >
> > > My setup should be something like this:
> > >
> > > sample.server.com serve as the main or official
> > site that users will access and the static files
> > should be located at sample.static.com. How am i
> > suppose to do it? both servers have nginx how
> > should configure that?
> >
> > sample.server.com:
> >
> > proxy_cache_path /path/to/cache levels=1:2
> > keys_zone=STATIC:10m
> > inactive=1h;
> >
> > server {
> >
> > location /static/ {
> > proxy_pass
> > http://sample.static.com;
> > proxy_cache STATIC;
> > proxy_cache_valid 1d;
> > proxy_cache_use_stale error timeout
> > invalid_header updating;
> > }
> >
> > sample.static.com:
> >
> > server {
> >
> > location /static/ {
> > root /path/to/files;
> > }
> >
> >
> > --
> > Igor Sysoev
> > http://sysoev.ru/en/
>
> Thanks Igor!!
> A few questions again :p
> Should the two server must have identical files? i mean same directory and same files?
Try to keep configuration as simple as possible to avoid any issues in future.
This means that file names should be identical.
You can use some directory mapping as
location /static/ {
proxy_pass http://sample.static.com/another/dir/;
}
or
location /static/ {
alias /path/to/some/files/;
}
but I prefere direct mapping.
> How should i check that it works?
Using logs.
> Is there any documentation i can refer this to as well?
http://wiki.nginx.org/NginxHttpProxyModule
--
Igor Sysoev
http://sysoev.ru/en/
More information about the nginx
mailing list