Score:0

Nginx- Setting up Firewall Bypass Prevention

de flag

I would like to Set up Firewall Bypass Prevention in my Nginx. To do so, I want to add the following directive to Nginx configuration:

location / {
    allow xxx.xx.xxx.x/xx;
    allow xxx.xx.xxx.x/xx;;
    allow xxxx:xxxx::/xx;
    allow xx.xxx.xxx.x/xx;
    allow xxx.xxx.x.x/xx;
    deny all;
    # Existing NGINX rules
}

I have already got location directive under server directive as follow:

location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        #try_files $uri $uri/ =404;
        try_files $uri $uri/ /index.php?q=$uri&$args;
        # Uncomment to enable naxsi on this location
        # include /etc/nginx/naxsi.rules
    }

The question is, do I need to add a new location directive for Firewall Bypass Prevention, or I have to append Firewall Bypass Prevention in existing location as following:

location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        #try_files $uri $uri/ =404;
        try_files $uri $uri/ /index.php?q=$uri&$args;
        # Uncomment to enable naxsi on this location
        # include /etc/nginx/naxsi.rules
        allow xxx.xx.xxx.x/xx;
        allow xxx.xx.xxx.x/xx;;
        allow xxxx:xxxx::/xx;
        allow xx.xxx.xxx.x/xx;
        allow xxx.xxx.x.x/xx;
        deny all;
       # Existing NGINX rules
    }

Any thought?

Score:1
cn flag

You most likely want to move allow and deny directive to the outside of any location and place directly within server {}. Then it will be applied to all locations.

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.