0

so I have a config.json file which I want to block external connections for such as people accessing it directly, It's required for my script to run on so I want to whitelist only my own server which is hosting the file and not any external connections.

I tried this in my VirtualHost config but it doesn't seem to be working as it gives 403 forbidden error for even my script which is on the same server.

<Files config.json>
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Files>

Please help, Thanks!

3 Answers3

0

Try this:

<Files config.json>
   Allow from 127.0.0.1
   Order allow,deny
</Files>
akond
  • 15,865
  • 4
  • 35
  • 55
0

In the following example, there is no authentication and all hosts in the 127.0.0.1 domain are allowed access; all other hosts are denied access.

2.2 configuration:

<Files config.json>
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Files>

2.4 configuration:

<Files config.json>
Require host 127.0.0.1
</Files>
Giri
  • 171
  • 4
0

'...on the same server...' != 127.0.0.1! I suspect your script is running on the same server but it does accesses the server process via public IP address.

If I'm right there are two possiblities.

  • reconfigure your script to access via localhost or 127.0.0.1
  • replace the address in the Allow from statement with the servers address
blafasel
  • 1,091
  • 14
  • 25