diff --git a/templates/vhost.conf b/templates/vhost.conf
index a3c9028b05d5acf5f7bf11faaa7d2da70830a3e8..e923bd928fa3724cb1716f972815bde93a907759 100644
--- a/templates/vhost.conf
+++ b/templates/vhost.conf
@@ -41,7 +41,13 @@
 {% endif %}
 
 {% if nextcloud.jail is defined and not php_fpm_socket|default(false) %}
-  ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:{{ nextcloud.jail.port }}/$1
+  <LocationMatch "/fpm-status">
+    Include /etc/apache2/{{ apache_conf_dir }}/global-deny.conf
+    ProxyPass fcgi://127.0.0.1:{{ nextcloud.jail.port }}
+  </LocationMatch>
+  <FilesMatch \.php$>
+    SetHandler "proxy:fcgi://127.0.0.1:{{ nextcloud.jail.port }}"
+  </FilesMatch>
 {% endif %}
 
   DocumentRoot {{ webRoot }}