D
D
Daeamon2015-08-24 13:40:35
Nginx
Daeamon, 2015-08-24 13:40:35

How to add a rule for the index.php page in the root of the site in NGINX and not affect other index.php in other directories with this rule?

Hello, I need to solve the problem, the entire site except for some dynamic pages is processed by nginx.
There is a module that is requested via index.php with get parameters.
When trying to add a caching bypass rule, the rule that is responsible for prohibiting data caching in the admin panel was somehow rewritten.

location = /index.php {
  if ($args ~ tmpl=module){
     proxy_pass http://localhost:81;
  }
}

How to make the rule work only for Index.php in the root of the site?
Or you can somehow apply the rule only if you access "index.php?tmpl=module"
After index.php?tmpl=module, more parameters can be added
All config
server {

   listen 80;
   server_name www.адрес_сайта.ру;

   return 301 http://адрес_сайта.ру$request_uri;
}

server {

   listen 666;
   server_name адрес_сайта.ру;

   location / {
     proxy_pass http://localhost:81;
   }
}

server {
  
   listen 80;
   server_name адрес_сайта.ру;

   access_log /var/log/nginx/proved-ru-access.log;
   error_log /var/log/nginx/proved-ru-error.log warn;
   

  location / {
    
     proxy_cache one;
     proxy_pass http://localhost:81;

     # Прячем куки других пользователей
     proxy_hide_header "Set-Cookie";
     # Игнорируем строки не кэшировать
     proxy_ignore_headers "Set-Cookie" "Cache-Control" "Expires";


   }

   #location = /index.php {
   #  if ($args ~ tmpl=module){
   #     proxy_pass http://localhost:81;
   #  }
   #}

   location /administrator/ {

    # http://kbeezie.com/apache-with-nginx

    # these two lines tell Apache the actual IP of the client being forwarded
    # Apache requires mod_proxy (http://bit.ly/mod_proxy) for these to work
    # Most Apache 2.0+ servers have mod_proxy configured already
 
    proxy_set_header X-Real-IP  $remote_addr;
    proxy_set_header X-Forwarded-For $remote_addr;
 
    # this next line adds the Host header so that apache knows which vHost to serve
    # the $host variable is automatically set to the hostname Nginx is responding to
 
    proxy_set_header Host $host; 

    # And now we pass back to apache
    # if you're using a side-by-side configuration the IP can be changed to
    # apache's bound IP at port 80 such as http://192.170.2.1:80

    proxy_pass http://localhost:81;

   }

   location /feeds/ {
     proxy_pass http://localhost:81;
   }

  location ~* /blogs {
     proxy_pass http://localhost:81;
  }

  location /component/jcomments/ {
      proxy_pass http://localhost:81;
  }
  
  location /components/com_blogs/assets/php/captcha/{
   proxy_pass http://localhost:81;
  }
  
  location /form.php{
    proxy_pass http://localhost:81;
  }
  
  location /test.php{
    proxy_pass http://localhost:81;
  }

  location /components/com_jcomments/helpers/notification.php{
    proxy_pass http://localhost:81;
  }
  
  location /search.html{
    proxy_pass http://localhost:81;
  }
  
   location ~*  \.(jpg|jpeg|png|gif|ico|pdf|swf|css|doc|docx|ppt|pptx|xls|xlsx)$ {
       expires 1y;
       root  /var/www/www-en;
  }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question