You are not logged in.

#1 2011-11-27 12:39:02

warped
Member
Registered: 2009-08-19
Posts: 41

Can't upload files to lighttp server

Hi *
I'm starting to have grey hairs abut this...
My sys is Archlinux (64bit), lighttpd 1.4.29-2, curl 7.22.
I'm trying to setup hhtp server with capability of upload files.
After basic setup I use following command to test functionality: 

curl -T "test_file" http://192.168.1.254/test/

curl's output is following:

[root@mythtv ~]# curl -T "test_file" http://192.168.1.254/test/

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>404 - Not Found</title>
</head>
<body>
<h1>404 - Not Found</h1>
</body>
</html>

Dir "test" exists & has 777.
All dirs upper to "test" also have 777.

lighttpd access log shows following:

192.168.1.254 192.168.1.254 - [24/Nov/2011:11:57:14 +0100] "PUT /test/test_file HTTP/1.1" 404 345 "-" "curl/7.22.0 (x86_64-unknown-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.0e zlib/1.2.5 libssh2/1.3.0"

My lighttpd.conf is following:

server.modules = (
"mod_rewrite",
"mod_access",
"mod_auth",
"mod_setenv",
"mod_fastcgi",
"mod_cgi",
"mod_webdav",
"mod_accesslog" )

server.document-root = "/var/http/"

server.errorlog-use-syslog = "enable"

index-file.names = ( "index.php", "index.html",
"index.htm", "default.htm" , "mythweb.php" )

mimetype.assign = (
".pdf" => "application/pdf",
".sig" => "application/pgp-signature",
".spl" => "application/futuresplash",
".class" => "application/octet-stream",
".ps" => "application/postscript",
".torrent" => "application/x-bittorrent",
".dvi" => "application/x-dvi",
".gz" => "application/x-gzip",
".pac" => "application/x-ns-proxy-autoconfig",
".swf" => "application/x-shockwave-flash",
".tar.gz" => "application/x-tgz",
".tgz" => "application/x-tgz",
".tar" => "application/x-tar",
".zip" => "application/zip",
".mp3" => "audio/mpeg",
".m3u" => "audio/x-mpegurl",
".wma" => "audio/x-ms-wma",
".wax" => "audio/x-ms-wax",
".ogg" => "application/ogg",
".wav" => "audio/x-wav",
".gif" => "image/gif",
".jar" => "application/x-java-archive",
".jpg" => "image/jpeg",
".jpeg" => "image/jpeg",
".png" => "image/png",
".xbm" => "image/x-xbitmap",
".xpm" => "image/x-xpixmap",
".xwd" => "image/x-xwindowdump",
".css" => "text/css",
".html" => "text/html",
".htm" => "text/html",
".js" => "text/javascript",
".asc" => "text/plain",
".c" => "text/plain",
".cpp" => "text/plain",
".log" => "text/plain",
".conf" => "text/plain",
".text" => "text/plain",
".txt" => "text/plain",
".dtd" => "text/xml",
".xml" => "text/xml",
".mpeg" => "video/mpeg",
".mpg" => "video/mpeg",
".mov" => "video/quicktime",
".qt" => "video/quicktime",
".avi" => "video/x-msvideo",
".asf" => "video/x-ms-asf",
".asx" => "video/x-ms-asf",
".wmv" => "video/x-ms-wmv",
".bz2" => "application/x-bzip",
".tbz" => "application/x-bzip-compressed-tar",
".tar.bz2" => "application/x-bzip-compressed-tar", # default mime type
"" => "application/octet-stream",
)

debug.log-request-handling = "enable"

accesslog.filename = "/var/log/web-access.log"

url.access-deny = ( "~", ".inc" )

$HTTP["url"] =~ "\.pdf$" {
server.range-requests = "disable" 
}

static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

server.pid-file = "/var/run/lighttpd.pid"

server.reject-expect-100-with-417 = "disable"

fastcgi.server = (
".php" => ((
"bin-path" => "/usr/bin/php-cgi",
"socket" => "/var/run/mythtv-php-fcgi.socket",
"broken-scriptfilename" => "enable",
"bin-environment" => (
"db_server" => "localhost",
"db_name" => "mythconverg",
"db_login" => "mythtv",
"db_password" => "mythtv" 
)
))
)

setenv.add-environment = (
             "db_server"   => "localhost",
             "db_name"     => "mythconverg",
             "db_login"    => "mythtv",
             "db_password" => "mythtv" 
)
cgi.assign = ( ".pl" => "/usr/bin/perl",
".cgi" => "/usr/bin/perl" )

url.rewrite-once = (
       "^/{1,2}mythweb/(css|data|images|js|themes|skins|[a-z_]+\.(php|pl)).*" => "$0",
       "^/{1,2}mythweb/(pl(/.*)?)$" => "/mythweb/mythweb.pl/$1",
       "^/{1,2}mythweb/(.+)$"       => "/mythweb/mythweb.php/$1",
       "^/{1,2}mythweb/(.*)$"       => "/mythweb/mythweb.php" 
   )
include "/etc/lighttpd/auth-inc.conf"

Can somebody hint me where issue might be ?

Thx n advance !

Offline

#2 2011-11-27 12:48:50

milomir
Member
From: Serbia
Registered: 2011-09-11
Posts: 17

Re: Can't upload files to lighttp server

put.php

<?php
$putdata = fopen("php://input", "r");
$fp = fopen("test_file", "w");
while ($data = fread($putdata, 1024))
  fwrite($fp, $data);
fclose($fp);
fclose($putdata);
?>
curl -T "test_file" http://192.168.1.254/test/put.php

you cannot just put files to any writeable directory on the host lol

Last edited by milomir (2011-11-27 12:52:37)


Hello Arch!

Offline

#3 2011-11-27 13:21:12

warped
Member
Registered: 2009-08-19
Posts: 41

Re: Can't upload files to lighttp server

@milomir,

Thx for replay.

While Your proposal is nice solution - this little now what I want to achieve.

In my application curl usage is automated (curl is called by user script).
My script has following entry:

/usr/local/bin/curl  -s -f -T "<file>" "<server>/<path>/<file>"

Strange enough that I have setup which worked OK sometime ago.
Since that time I do few system upgrades - and recently I discover that posting files via curl isn't working.

Last days I was trying many combination including clean install of 64bit arch in VM and try to play with default settings.
No matter what I'm doing - all the time I'm getting 404.

I still think I miss something in configuration as i don't believe vanilla Arch/Lighttpd/Curl can't be used as http upload service with standard curt usage (like way it is used in my script).

So maybe my original Q should be following: why I can't upload files with standard curl/wget usage ?

-br

Offline

#4 2011-11-27 13:47:37

milomir
Member
From: Serbia
Registered: 2011-09-11
Posts: 17

Re: Can't upload files to lighttp server

as i said, i don't think you can just "PUT" (as in PUT method) files in a writeable directory, if that was possible then anyone could upload files, and do whatever they want..

if you don't want to use a script to handle the upload for you, then use webdav, it works with your method, you just PUT a file in a webdav directory..


Hello Arch!

Offline

#5 2011-11-27 20:13:57

warped
Member
Registered: 2009-08-19
Posts: 41

Re: Can't upload files to lighttp server

@milomir,

Thx for hint with webdav.
This is exactly why I'm looking for. Now works as expected.
Once again - thx for help !
-br

Offline

Board footer

Powered by FluxBB