Reverse proxy- cache not passing the cookies from the proxied server.. Why?

David Taveras d3taveras38d3 at gmail.com
Mon Mar 1 20:43:52 MSK 2010


Hello all.


I have the following config for some reason the PHPSESSION is not
passing back from the proxied server to the client. I have tested this
on .php files (which according to the logs each request to .php is
getting always asked on the proxied server ) and .html pages.. but no
go.

If I turn caching off everything works.

What could be the problem?


pid               /var/run/nginx.pid;
user              _nginx _nginx;
worker_processes  10;

events {
    worker_connections  1024;
}

http {
 ## MIME types
 #include            /etc/nginx_mime.types;
  default_type       application/octet-stream;

 ## Size Limits from Clients
  client_body_buffer_size     128K;
  client_header_buffer_size   128K;
  client_max_body_size          1M;
  large_client_header_buffers 1 1k;

 ## Timeouts from Clients
  client_body_timeout   60;
  client_header_timeout 60;
  keepalive_timeout     60 60;
  send_timeout          60;

 ## General Options
  ignore_invalid_headers   on;
  keepalive_requests      100;
  ##recursive_error_pages    on;
  sendfile                 on;
  server_name_in_redirect off;
  server_tokens           off;

 ## TCP options (optimization)
  tcp_nodelay on;
  tcp_nopush  on;

 ## Log Format
  log_format  main  '$remote_addr $host $remote_user [$time_local] "$request" '
                    '$status $body_bytes_sent "$http_referer"
"$http_user_agent" '
                    '"$request_time"';

 ## Proxy options
  proxy_buffering           on;


  proxy_cache_min_uses       1;
  proxy_cache_path          /var/log/nginx/cache_temp/ levels=1:2
keys_zone=cache:10m inactive=10m max_size=512M;

  proxy_ignore_client_abort off;
  proxy_intercept_errors    off;
  proxy_next_upstream       error timeout invalid_header;
  proxy_redirect            off;
  proxy_set_header          X-Forwarded-For $remote_addr;
  proxy_connect_timeout     60;
  proxy_send_timeout        60;
  proxy_read_timeout        60;



  server {
      access_log  /var/log/nginx/my.site.com80-access.log main;
      error_log   /var/log/nginx/my.site.com80-error.log;
      listen      234.133.244.81:80 default;
      root        /usr/local/nginx/html;
      server_name _;

      ## Only allow these request methods
      if ($request_method !~ ^(GET|HEAD|POST)$ ) {
         return 444;
      }


      location / {
        proxy_pass  http://www.mysite.com/;
        proxy_cache            cache;
      }
      }


  server {
      access_log  /var/log/nginx/my.site.com443-access.log main;
      error_log   /var/log/nginx/my.site.com443-error.log;
      index       index.html;
      listen      234.133.244.81:443 default;
      root        /usr/local/nginx/html;
      server_name _;

      ssl on;
      ssl_certificate /etc/nginx/my.site.com_ssl.crt;
      ssl_certificate_key /etc/nginx/my.site.com_ssl.key;
      ssl_ciphers HIGH:!ADH:!MD5;
      ssl_prefer_server_ciphers on;
      ssl_protocols SSLv3;
      ssl_session_cache shared:SSL:1m;
      ssl_session_timeout 5m;

      location / {
        proxy_pass  https://my.site.com:443/;
        proxy_cache            cache;
       # proxy_cache_valid      200 24h;

      }

  }


Andres



More information about the nginx mailing list