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.

all 9 comments

sorted by: hot top controversial new old
[โ€“] 2 points 1 year ago (1 child)

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

location ~* \/(fileA|fileB)\.txt$ {
        return 404 'nothing here';
}
  • source
  • hideshow 1 child comment
  • [โ€“] [S] 2 points 1 year ago* (last edited 1 year ago) (1 child)

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

  • source
  • hideshow 1 child comment
  • [โ€“] 2 points 1 year ago (2 children)

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

  • source
  • hideshow 2 child comments
  • [โ€“] [S] 1 point 1 year 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 @ramble81@lemmy.zip

  • source
  • [โ€“] [S] 1 point 1 year ago* (last edited 1 year ago)

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

    because

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

    Does not works either...

  • source