File_get_contents on plugin php file gives 403 error

I’m trying to use file_get_contents() on a php-file in my custom plugin but this gives me a 403 error. I’m guessing it get’s blocked somehow by the nginx config trellis uses.

Any ideas how to allow this?

Thanks a lot in advance!

Searching for “file_get_contents 403” on Google leads to lots of results

If you’re looking for help, first let us know what you’ve tried to do so far and what doesn’t work

1 Like

Hi Ben, thanks for your reply. I should’ve been more detailed. I had Googled of course and tried various things already.

I tried getting the file’s contents using cURL. I’ve also tried sending a User Agent with the header using file_get_contents. Both options still give me a 403.

It seems that I have fixed it by adding a nginx location block in the folder ‘nginx-includes’ allowing specific access to the php-file for the ip and denying the rest.

1 Like