6

I'd like to enable on my Apache 2.4 under linux the PUT and DELETE methods. When clients try to invoke such methods I get a "405 Method Not Allowed" as answer.

On server side my PHP script handle such requests but it seems filtered by the server itself (that's makes the difference from the similar already answered question - Moreover other questions seems to refers to an old version of Apache).

Can I manage some configurations on .htaccess file or I have to modify the .conf files under /etc/apache2?

Thanks a lot.

Francesco Piraneo G.
  • 882
  • 3
  • 11
  • 25
  • Possible duplicate of [How to enable and use HTTP PUT and DELETE with Apache2 and PHP?](http://stackoverflow.com/questions/2934554/how-to-enable-and-use-http-put-and-delete-with-apache2-and-php) – Matt S May 27 '16 at 13:39
  • 1
    No. My script already handles such methods but as stated they seems filtered out by apache; my script is not invoked at all. – Francesco Piraneo G. May 27 '16 at 13:42

4 Answers4

8

Try the following changes on your server:

Open "/etc/httpd/conf/httpd.conf" and look for the following blocks:

<Limit GET POST OPTIONS PROPFIND>
  Order allow,deny Allow from all
</Limit>
<LimitExcept GET POST OPTIONS PROPFIND>
   Order deny,allow Deny from all
</LimitExcept>

Then just add PUT and DELETE after PROPFIND. Then Restart httpd by "/sbin/service httpd restart" or service httpd restart.

Note: In some servers , mostly the ones with a control panel (DA,cPanel,..) you may change this file :/etc/httpd/conf/extra/httpd-directories.conf

I hope it solves your problem.

Sinai
  • 620
  • 1
  • 14
  • 36
0

You can use allowmethods_module to enable that.

It's been available since apache version 2.3 but still experimental though.

<Location "/path/to/directory">
   AllowMethods PUT DELETE
</Location>
Muhammad Reda
  • 26,379
  • 14
  • 93
  • 105
0

For Debian/Ubuntu.

In your conf:

<Location "/">
    AllowMethods GET PUT
</Location>

In console:

sudo a2enmod allowmethods
sudo systemctl restart apache2.service
Neurotransmitter
  • 6,289
  • 2
  • 51
  • 38
-3

I got the same error and the root cause is the redirects to https (80-443) are not occurring which one of the things are causing the docker client to fail while allowing the browser to work. I added below directives in Apache httpd (apache2) and it worked for me.

<VirtualHost *:80>
        RedirectPermanent / https://%{SERVER_NAME}/
        RewriteEngine On
        RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
</VirtualHost>


<VirtualHost *:443>
        SSLEngine on
        SSLCertificateFile /etc/ssl/certs/apache-selfsigned.crt
        SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key
        #   General setup for the virtual host
        ServerName example.org
        ServerAdmin help@example.com
        ErrorLog /tmp/error_log
        SSLProxyEngine On
        ProxyRequests Off
        <Proxy *>
                Order deny,allow
                Allow from all
        </Proxy>
        AllowEncodedSlashes NoDecode

        ProxyPreserveHost On
        ProxyPass / http://<BackendIP>/ connectiontimeout=10 timeout=3600
        ProxyPassReverse / http://<BackendIP>/
</VirtualHost>
Chance
  • 405
  • 4
  • 8