2

Well, i have my site.conf file like this:

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_cache_key "$scheme$request_method$host$request_uri";
proxy_cache_path /etc/nginx/cache/pag levels=1:2 keys_zone=APP:100m inactive=1m;
proxy_temp_path /etc/nginx/cache/tmp;

add_header X-Cache $upstream_cache_status;

server {
 listen 80;

 root   /etc/nginx/html;
 index  index.html index.htm;

 server_name www.example.com;

 error_page  404              /404.html;

 location  /404.html {
    internal;
 }

 location / {
    proxy_pass http://127.0.0.1:8080/;
    proxy_cache APP;
    proxy_cache_valid 200 1m;
    proxy_cache_methods POST;
    expires 1m;
 }
}

With this configuration, everything (including POST request methods) is cached for 1 min, OK.

What i need? I need that only this pages can be cached:

1) www.example.com
2) www.example.com/index.html
3) www.example.com/test/page.html
4) www.example.com/test/text.txt (this is a file requested by POST thru page.html, and i need it cached also)
5) www.example.com/test/page2.php?var1=val1&var2=val2 (val1 and val2 are dynamics)

My question is: What i have to put in location / to match the 1-5 items? Like this:

location (1-5 items match) {
    proxy_pass http://127.0.0.1:8080/;
    proxy_cache APP;
    proxy_cache_valid 200 1m;
    proxy_cache_methods POST;
    expires 1m;
 }

Other pages (not cached) will be automatically redirected to 127.0.0.1:8080. I know this can be do like this:

 location / {
    proxy_pass http://127.0.0.1:8080/;
 }

NOTE 1: Other PHP pages receive POST|GET request methods, but i don't need it in cache, only aboves.

NOTE: 2 127.0.0.1:8080 is an apache server that runs PHP, so i can request PHP pages.

robe007
  • 3,523
  • 4
  • 33
  • 59
  • 1
    This question appears to belong on another site in the Stack Exchange network because its not about programming. Perhaps [Super User](https://www.superuser.com/) or [Server Fault](http://serverfault.com/). – jww May 11 '14 at 11:47

1 Answers1

0

Since apache runs on the same host, simply serve the html files you do not want cached through nginx. As for the php pages, send the correct expiration headers in your application and everything will work correctly.

  • Nope, i need to serve cached files through nginx. The problem is, that i want no know how to modify the location / to match the 1-5 items in list. Note: I edited my question (: – robe007 May 08 '14 at 16:01