A
A
AstonMartin2015-12-30 05:54:49
Nginx
AstonMartin, 2015-12-30 05:54:49

Need help with a simple nginx regex?

Guys, help, plz, with a simple nginx config?
I have this config now:

server {
    listen       80;

    server_name  domain.com;
    root      /home/www/domain.com;

    access_log  /var/log/nginx/domain.com.access.log  main;
    error_log  /var/log/nginx/domain.com.error.log;

    location / {
        root   /home/www/domain.com;
        index  index.php;
    }

    location ~* \.(JPG|jpg|jpeg|png|css|gif|js|ico)$ {
        root /home/www/domain.com;
        expires 1d;
        access_log off;
    }

    location /ab/account/ {
        try_files $uri $uri/ =404;
        auth_basic "Restricted Content";
        auth_basic_user_file /etc/nginx/passwd;

        location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
        }

    }

    location ~* o1=mm {
        proxy_pass http://domain2.com;
    }

    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    location ~ /\.ht {
        deny  all;
    }
}

It was necessary to make all requests containing the substring o1=mm be proxyed to domain2.com. Accordingly inserted location.
I make a request for example: domain.com/?aaa=158&bbb=6022&o1=mm&o2=1111122222 and get 403 in response.
But it is necessary that nginx proxy the request to domain2.com/?aaa=158&bbb=6022&o1=mm&o2=1111122222 and return the response to the visitor.
Tell me plz? It seemed like such a simple thing, but point-blank I don’t understand why it doesn’t work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Softer, 2015-12-30
@AstonMartin

GET parameters are not checked in location. URI only.
GET to $args in general and to $arg_o1 in particular.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question