vs-fam

Active Member
PartnerNOC
Mar 18, 2010
36
4
58
Hi,

I'm trying to find out if PUT method is enabled (most likely not, but just to be sure). Can't get netcat to find out, I get no output.

However, is it possible to enable it? I did some search but no luck.

Thanks
 

vs-fam

Active Member
PartnerNOC
Mar 18, 2010
36
4
58
Ok, netcat found out PUT is not enabled. How can PUT be enabled?

Thanks
 

vs-fam

Active Member
PartnerNOC
Mar 18, 2010
36
4
58
Unfortunately spoke too soon. After I ran into mod security blocks I'm stuck again. Now I get "501 Not implemented" and GET to the folder not supported.

Any ideas?

I'll keep digging
 
Last edited:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,260
463
Hello,

Could you elaborate on the Mod_Security issues? What error messages do you see in /usr/local/apache/logs/error_log when this happens?

Thank you.
 

vs-fam

Active Member
PartnerNOC
Mar 18, 2010
36
4
58
Thanks Michael and Peter for following this thread. It's finally solved. It was still mod security issues and a bit of .htaccess rules to forward the request accordingly.

2 mod security rules were blocking the requests:
ID 1234123435
ID 1234123429

Disable them or modify them. I disabled them.

To sum up for future reference:

This is the include file for the vhost to enable PUt method:
Code:
<Directory /path/to/specific/folder/to/handle/put/requests>
   <Limit PUT GET POST DELETE HEAD OPTIONS>
       Order allow,deny
       Allow from all
   </Limit>
</Directory>
This is the .htaccess content (with basic auth):
Code:
AuthType Basic
AuthName "Your title"
AuthUserFile "/path/to/passwd"
require valid-user

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.+$ - [NC,L]
RewriteCond %{REQUEST_METHOD} (PUT|DELETE)
RewriteRule .* put.php
This is the put.php file that will handle the PUT request:
PHP:
$putdata = fopen("php://input", "r");
$file="your_filename.txt";
$fp = fopen($file, "w");
while ($data = fread($putdata, 1024)){
    fwrite($fp, $data);
}

fclose($fp);
fclose($putdata);
Everything has to be in the same folder or update your paths accordingly.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,260
463
I am happy to see the issue is now resolved.

Thank you.
 

ramorse

Well-Known Member
Sep 6, 2003
256
5
168
cPanel Access Level
Root Administrator
I have client that has requested this. I have tried implementing by following documentation and creating a user defined .conf file. Haven't tried the .htaccess yet as I am not sure what part it plays. But it so far hasn't worked.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,260
463
I have client that has requested this. I have tried implementing by following documentation and creating a user defined .conf file. Haven't tried the .htaccess yet as I am not sure what part it plays. But it so far hasn't worked.
Hello :)

You mentioned following the documentation and creating a user defined .conf file. Could you let us know which specific steps you have taken so we can determine if you made any mistakes?

Thank you.
 

ramorse

Well-Known Member
Sep 6, 2003
256
5
168
cPanel Access Level
Root Administrator
Sure. I followed the steps at Modify Virtualhost Containers With Include Files - EasyApache - cPanel Documentation in that, as I am running Apache 2.2 and this is a non SSL account I went to /usr/local/apache/conf/userdata/std/2_2/

I created a userdirectory as one for that user didn't exist. Then in that directory I created directory for the domain (ie user.com). In that directory I created a file called allowput.conf. In that file I put:

<Directory /home/theusername/public_html/testcalendar>
<Limit PUT GET POST DELETE HEAD OPTIONS>
Order allow,deny
Allow from all
</Limit>
</Directory>
</Directory>

Then I restarted Apached.
Now one complication may be that I am using Cloud Linux. But just in case that would cause some change like this to not work I ran cagefsctl --force-update.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,260
463
Haven't tried the .htaccess yet as I am not sure what part it plays.
This is what forwards the PUT request. You must follow the step that suggests editing the .htaccess and creating the put.php file if you want to take the same action as the original poster. Note the Authorization entries in the example .htaccess file provided by the original poster are only required if you are password protecting the directory.

Thank you.
 

ramorse

Well-Known Member
Sep 6, 2003
256
5
168
cPanel Access Level
Root Administrator
OK I created the put.php file and chownd to the user. Although I did put *.ics for the $filename. And we have the .htaccess in there withouth the password lines. Still getting a 500 error.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,260
463
OK I created the put.php file and chownd to the user. Although I did put *.ics for the $filename. And we have the .htaccess in there withouth the password lines. Still getting a 500 error.
What's the specific error output to /usr/local/apache/logs/error_log when this happens? Have you tried entering one specific filename instead of a wildcard to see if you get the same result?

Thank you.
 

ramorse

Well-Known Member
Sep 6, 2003
256
5
168
cPanel Access Level
Root Administrator
There is nothing related to this in /usr/local/apache/logs/error_log. I changed it back to the specific file name in put.php and asked him to try again. He got the same result. I checked the error_log again. Nothing for the domain for today. I asked him for a screen shot of what happens when he tries this and the erro mesage is from his desktop Calendar app. So, it may not be getting written to the logfile.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,260
463
I asked him for a screen shot of what happens when he tries this and the erro mesage is from his desktop Calendar app. So, it may not be getting written to the logfile.
What's the specific error message in their application?

Thank you.
 

ramorse

Well-Known Member
Sep 6, 2003
256
5
168
cPanel Access Level
Root Administrator
At one point the screen shot said: "path to location" is not a location that supports this request.

Later after adding the .htaccess and put.php with the specific file he was trying to put (a .ics file) it just said "failed. The server responded with "500".
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,260
463
We won't be able to troubleshoot your custom script, but you can open a support ticket using the link in my signature so we can review your Apache logs to determine if there's any output related to that connection attempt. Post the ticket number here and we can update this thread with the outcome.

Thank you.