Score:0

Nginx if cookie exists, use proxy, if not, run php to create cookie and check again

in flag

I'm trying to create a condition with nginx that if a cookie does not exists, the nginx run index.php to create the cookie, and if a cookie exists, then the nginx goes to proxy.

How I can do this? I'm tried like this:

location / {

  if ($cookie_test = false) {
     try_files $uri $uri/ /teste.php?$args;
     include /etc/nginx/fastcgi_params;
     fastcgi_pass 127.0.0.1:9000;

  } else {

       add_header 'Content-Type' 'application/vnd.apple.mpegurl';

       proxy_set_header        X-Real-IP       $remote_addr;
       proxy_set_header        REMOTE_ADDR     $remote_addr;
       proxy_set_header        Host            $host;
       proxy_redirect          off;
       proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_connect_timeout 90;
       proxy_send_timeout 90;
       proxy_read_timeout 90;
       client_max_body_size 10m;
       client_body_buffer_size 128k;
       proxy_buffer_size 4k;
       proxy_buffers 4 32k;
       proxy_busy_buffers_size 64k;

       proxy_pass https://127.0.0.1:8080;

  }
}

but getting this error:

"try_files" directive is not allowed here

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.