http-sorted-querystring #

Nginx Sorted Querystring Module

Source: upstream source

Directives

sorted_querysting_filter_parameter #

syntax: sorted_querysting_filter_parameter 1+ args;  ·  context: http, server, location, location-if

It is also possible to remove one or more undesired query parameters by defining their name with the sorted_querysting_filter_parameter directive, like sorted_querystring_filter_parameter <parameter_name> [<parameter_name> <parameter_name> ...];. _This module is not distributed with the Nginx source.

Example

pid         logs/nginx.pid;
error_log   logs/nginx-main_error.log debug;

# Development Mode
master_process      off;
daemon              off;
worker_processes    2;

events {
  worker_connections  1024;
  #use                 kqueue; # MacOS
  use                 epoll; # Linux
}

http {
  default_type    text/plain;

  types {
      text/html   html;
  }

  log_format main  '[$time_local] $host "$request" $request_time s '
                   '$status $body_bytes_sent "$http_referer" "$http_user_agent" '
                   'cache_status: "$upstream_cache_status" args: "$args '
                   'sorted_args: "$sorted_querystring_args" ';

  access_log       logs/nginx-http_access.log;

  proxy_cache_path /tmp/cache levels=1:2 keys_zone=zone:10m inactive=10d max_size=100m;

  server {
    listen          8080;
    server_name     localhost;

    access_log       logs/nginx-http_access.log main;

    location /filtered {
      sorted_querysting_filter_parameter v _ v time b;

      proxy_set_header Host "static_files_server";
      proxy_pass http://localhost:8081;

      proxy_cache zone;
      proxy_cache_key "$sorted_querystring_args";
      proxy_cache_valid 200 1m;
    }

    location / {
      proxy_pass http://localhost:8081;

      proxy_cache zone;
      proxy_cache_key "$sorted_querystring_args";
      proxy_cache_valid 200 10m;
    }
  }

  server {
    listen          8081;

    location / {
      return 200 "$args\n";
    }
  }
}

↑ back to index