[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Apache 2.4. Autoriser la méthode PUT pour un chemin spécifique



Bonjour,

J'ai des fichiers dans une arboresence /srv/tftp/foo d'une machine sous Buster
Je souhaite pouvoir "pousser" des fichiers dans cette arborescence avec la méthode PUT via un serveur Apache 2.4 sur lequel le paquet php est installé.

Comment procéder proprement ?

J'ai le fichier file_upload.php au contenu suivant:

<?php
//error_log("Current user is ".get_current_user());

$data = "">$output_filename = $_SERVER['DOCUMENT_ROOT'].$_SERVER['REQUEST_URI'];

$code = file_put_contents($output_filename, $data);
if (strlen($data) !== $code)
   error_log("Error code while writing ".$output_filename.": input length is ".strlen($data)." while output length is ".$code);

?>


J'ai aussi un fichier de config Apache, activé avec a2enconf :
<VirtualHost *:80>

    ServerAdmin webmaster@localhost

    Alias /foo /srv/tftp/foo
    DocumentRoot /srv/tftp/foo
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <Directory /srv/tftp/foo/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Require all granted
        Script PUT /srv/tftp/foo/file_upload.php
    </Directory>

</VirtualHost>

J'ai:
curl -T foo.cfg http://192.168.1.1/foo/foo.cfg
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>405 Method Not Allowed</title>
</head><body>
<h1>Method Not Allowed</h1>
<p>The requested method PUT is not allowed for this URL.</p>
<hr>
<address>Apache/2.4.38 (Raspbian) Server at 192.168.1.1 Port 80</address>
</body></html>

Comment corriger ?

Slts

Reply to: