Nginx with php configuration how to block all requests/urls other than two?

B.R. reallfqq-nginx at yahoo.fr
Thu Jan 29 17:56:30 UTC 2015


​Chained maps maybe?​

http {
    map $arg_option $step2 {
        default 1;
        com_hwdmediashare $arg_task;
    }

    map $step2 $step3 {
        default 1;
        addmedia.upload $request;
    }

    map $step3 $blocked {
        default 1;
        ~*(?:\?|&)?base64encryptedstring 0;
    }

    server {
        location / {
            return 404;
        }

        location /index.php {
            if ($blocked) {
                return 404;
            }
        }

        location /media/com_hwdmediashare/assets/swf/Swiff.Uploader.swf {
        }
    }
}
---
*B. R.*

On Thu, Jan 29, 2015 at 6:29 PM, itpp2012 <nginx-forum at nginx.us> wrote:

> In the map flip the 1 and 0 around, if $allowonly=1 then the IF is true
> (unless that's what you want).
>
> General rule for IF's; only use it to return a state.
>
> if ..... return ....
> continue with complex configuration items.
>
> Don't do: 'if ..... do complex things ....' (unless proceeded with Lua
> finishing with an nginx if....return)
>
> If you want to expand the logic what is ok and what not, have a look at my
> conf\nginx-simple-WAF.conf
> where 3 maps are combined into 1 result map.
>
> In your case you could use 2 mappings, 1 for normal requests and 1 for
> passed-on php requests.
>
> Posted at Nginx Forum:
> http://forum.nginx.org/read.php?2,256336,256339#msg-256339
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20150129/3a546a0d/attachment.html>


More information about the nginx mailing list