Skip to content

Commit 6ff87c3

Browse files
committed
Add Nginx rules to security documentation, in order to prevent execution of PHP files from the uploadable-files directories
1 parent 7c0a032 commit 6ff87c3

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

documentation/security.html

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ <h2><a name="5.Files-permissions"></a>5. Restricting files permissions</h2>
105105
account we authorize overrides through .htaccess, we need to set
106106
something that a .htaccess file cannot revert, and we need to set it
107107
for each of those directories. This can be done as follows inside
108-
your VirtualHost definition in Apache (you'll have to translate it for
109-
Nginx configurations), where "/var/www/URL/" is the path of your VirtualHost web root:<br />
108+
your VirtualHost definition in Apache, where "/var/www/URL/" is the path of your VirtualHost web root:<br />
110109
<pre>
111110
&lt;Directory /var/www/URL/app/cache&gt;
112111
php_admin_value engine Off
@@ -133,6 +132,25 @@ <h2><a name="5.Files-permissions"></a>5. Restricting files permissions</h2>
133132
php_admin_value engine Off
134133
&lt;/Directory&gt;
135134
</pre>
135+
136+
For Nginx, this would look like the following rules. However, do
137+
remember that Nginx interprets rules in order of appearance, so these
138+
rules would have to be at the top of your location rules to take the
139+
highest priority:
140+
<pre>
141+
location ~ ^/app/(cache|courses|home|logs|upload)/.*\.(php|php4|php5)$ {
142+
deny all;
143+
}
144+
location ~ ^/main/default_course_document/images/.*\.php$ {
145+
deny all;
146+
}
147+
location ~ ^/main/lang/.*\.php$ {
148+
deny all;
149+
}
150+
location ~ ^/web/css/.*\.php$ {
151+
deny all;
152+
}
153+
</pre>
136154
<br />
137155
<hr />
138156
<h2><a name="6.HSTS">HTTP Headers Security</a></h2>

0 commit comments

Comments
 (0)