Hi,

I have this rule in my nginx config file

	location ~* \/(fileA.txt|fileB.txt)$ {
		return 404 'nothing here';
	}

but it’s not working

but

	location /fileA.txt {
		return 404 'nothing here';
	}

is working…

Any idea what’s wrong ?

Thanks.

  • elbucho@lemmy.world
    link
    fedilink
    English
    arrow-up
    2
    ·
    3 months ago

    You aren’t escaping your periods. Try like this:

    location ~* \/(fileA|fileB)\.txt$ {
            return 404 'nothing here';
    }
    
  • x00z@lemmy.world
    link
    fedilink
    English
    arrow-up
    2
    ·
    3 months ago

    You might have another location block before it that catches the route.

  • Rick_C137OP
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    3 months ago

    Never mind, I understood my mistake… This nginx built didn’t come with ngx_http_rewrite_module so return will not works.

    • Rick_C137OP
      link
      fedilink
      arrow-up
      1
      ·
      3 months ago

      Apparently ngx_http_rewrite_module “module” is installedby default with nginx… damn thay should use diffrent terms for what could be install or not at compile time…

  • Rick_C137OP
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    3 months ago

    Actually I don’t think the error lay in the regex.

    because

    	location /fileA.txt {
    		return 404 'nothing here';
    	}
    

    Does not works either…

  • Rick_C137OP
    link
    fedilink
    arrow-up
    1
    ·
    3 months ago

    Finally it works as it should I update my old nginx version to newest freenginx and read Thoroughly the location documentation and this post thanks to @[email protected]