Forum Moderators: phranque
<Files ~ "\.php$">
Order Allow,Deny
Deny from 111.111.111.255/24
Deny from 112.111.111.255/24
</Files> EXCEPT when there's a forward slash
Instead of doing a regular .htaccess deny IP, should I just do it like this:
SetEnvIfNoCase Request_URI "\.php" ban
Because of the way PHP is installed on your server means that requests for ".php" files are effectively proxied to the backend PHP engine and your .htaccess file is bypassed entirely for these requests.
"At the end of the URL? Is this a directory? Or a file (with PATH_INFO)? Or some virtual URL-path?"
example.com/folder/ example.com/folder/*.php sometimes it is simpler to change permissions.
example.com/folder/search.php Deny from 111.111.111.255/24
Deny from 112.111.111.255/24
Was this bit typed at random for posting purposes? Run PHP as FPM application served by nginx
A directory.
.htaccess works here:
example.com/folder/
This is how it beginsOK, so the question is about mod_auth-whatever-it-was-called-in-2.0, as indicated by the Allow/Deny syntax. Unless you've got a seriously antiquated server, we're talking about 2.4 with mod_access_compat. In that case, you have to watch our for conflicts with mod_authz_core, the one that uses directives in “Require” form, either in the same htaccess or deeper down.
the URL is /example/index.phpIf in fact you are using <Files> envelopes, then you have to put URL out of your mind. The envelope applies to physical files--and, of course, it only applies to files that are on the path served by the current htaccess. If the php files are elsewhere in the server, a <Files> envelope will have no effect. (<Location> might, but it can't be used in htaccess.)
But the actual question is, are the rules-that-don't-work located inside a <Files> envelope?
Because of the way PHP is installed on your server means that requests for ".php" files are effectively proxied to the backend PHP engine and your .htaccess file is bypassed entirely for these requests.
"EXCEPT when there's a forward slash and anything.php."
* Or earlier still, in your firewall.
Managing Custom Rules
To add a custom rule:
1. Go to Extensions > Firewall > Modify Plesk Firewall Rules.
.
.
.
6.To specify the IP address or network address, type it into the Add IP address or network input box, and click Add.
7. Specify the action that will be applied to the communications that match the defined criteria: allow or deny.
8.Click OK to submit the rule
are you seeing any clues of these requests in your apache web server log files?
order allow,deny
allow from all
Deny from x.x.x.x/xx
Anything in particular that I should be looking for?Yes: look for accesses from your own IP in the appropriate time frame. If you don't see yourself at all, that confirms that php is routed a different way. (But what about supporting files such as images and stylesheets? Do those live in the same place as the php?)
Is my .htaccess coded wrong for the latest version of Apache?Your access rules worked in Apache 2.2 using mod_auth-whatever. They continue to work in Apache 2.4 thanks to mod_access_compat, created solely to prevent servers everywhere from exploding. It is safe to predict that Apache 2.6 will no longer have mod_access_compat, because everyone will have long since upgraded their access controls to use the new format. It can be done with little more than a few global replaces.
Checked Apache and Nginx access/error/etc logs and didn't really see anything that stood out.
Anything in particular that I should be looking for?
They continue to work in Apache 2.4
Yes: look for accesses from your own IP in the appropriate time frame.
...i would also be looking for clues that your request got sent to the nginx server before apache had a chance to block it.
"Plesk configures it as a reverse proxy server that stands between the Internet and Apache (see the diagram below).
This means that nginx becomes a frontend web server that processes all incoming requests from site visitors.
The requests are sent to Apache which, in turn, distinguishes requests for static and dynamic content. If a request is for a static file (such as jpg, css, html, and so on), Apache passes the request through all registered handlers (applies .htaccess directory-level configuration, rewrites a URL, and so on) and returns to nginx a response which contains only the location of the requested file on the file system.
nginx locates the file and sends it to the client. If the request is for a dynamic file (such as a PHP script), Apache executes the file and sends the response to nginx, which delivers it to the client.
The PHP setting for my site is:
Run PHP as FPM application served by nginx
Is .htaccess only "ignored" when a request directly references a .php files, e.g. example.com/whatever/script.php, or also when a PHP script is the directory index file of a path like example.com, i.e. where there's no .php extension in the URI?
DirectoryIndex index.php
and, if so, does “index.php” exist anywhere as a real, physical file? (I had to double-check this in docs. The default remains “index.html” and-that's-all, so if the site uses index.php, it has to say so somewhere.)
location ~ \.php$ {