[Solved] 411 - Length Required
Added by Koi8 over 7 years ago
I got this error on every single Post I made , my system is CentOS 6.9 using php 5.6 on CGI mode
here contents of my file lighttpd.conf
## /etc/lighttpd/lighttpd.conf ## check /etc/lighttpd/conf.d/*.conf for the configuration of modules. var.log_root = "/var/log/lighttpd" var.server_root = "/var/www" var.state_dir = "/var/run" var.home_dir = "/var/lib/lighttpd" var.conf_dir = "/etc/lighttpd" #var.log_root = "/logs" #var.server_root = "/" #var.state_dir = "/run" #var.home_dir = "/lib/lighttpd" #var.vhosts_dir = "/vhosts" #var.conf_dir = "/etc" #server.chroot = "/srv/www" ## used in: ## conf.d/evhost.conf ## conf.d/simple_vhost.conf ## vhosts.d/vhosts.template var.vhosts_dir = server_root + "/vhosts" var.cache_dir = "/var/cache/lighttpd" ## conf.d/fastcgi.conf ## conf.d/scgi.conf var.socket_dir = state_dir + "/sockets" include "modules.conf" server.port = 80 server.use-ipv6 = "disable" #server.bind = "localhost" server.username = "lighttpd" server.groupname = "lighttpd" #server.core-files = "disable" server.document-root = server_root #server.tag = "lighttpd" server.pid-file = state_dir + "/lighttpd.pid" ####################################################################### ####################################################################### server.errorlog = log_root + "/error.log" #server.errorlog-use-syslog = "enable" include "conf.d/access_log.conf" include "conf.d/debug.conf" ####################################################################### server.event-handler = "linux-sysepoll" ## sendfile - is recommended for small files. ## writev - is recommended for sending many large files server.network-backend = "writev" #server.max-fds = 2048 ## Default: 1024 #server.listen-backlog = 128 ## disable, simple or fam. server.stat-cache-engine = "simple" ## max-connections == max-fds/2 (maybe /3) server.max-connections = 1024 ## How many seconds to keep a keep-alive connection open, #server.max-keep-alive-idle = 5 ## How many keep-alive requests until closing the connection. #server.max-keep-alive-requests = 16 #server.max-request-size = 0 #server.max-read-idle = 60 ## Time to write to a socket before we consider it idle. #server.max-write-idle = 360 #server.kbytes-per-second = 128 #connection.kbytes-per-second = 32 ## files to check for if .../ is requested ## index-file.names = ( "index.php", "index.rb", "index.html", ## "index.htm", "default.htm" ) index-file.names += ( "index.xhtml", "index.html", "index.htm", "default.htm", "index.php" ) ## deny access the file-extensions url.access-deny = ( "~", ".inc" ) ## disable range requests for pdf files $HTTP["url"] =~ "\.pdf$" { server.range-requests = "disable" } #url.rewrite = ( "^/$" => "/server-status" ) #url.redirect = ( "^/wishlist/(.+)" => "http://www.example.com/$1" ) #$HTTP["host"] =~ "^www\.(.*)" { # url.redirect = ( "^/(.*)" => "http://%1/$1" ) #} ## .php, .pl, .fcgi are most often handled by mod_fastcgi or mod_cgi static-file.exclude-extensions = ( ".php", ".pl", ".fcgi", ".scgi" ) ## error-handler for all status 400-599 #server.error-handler = "/error-handler.html" #server.error-handler = "/error-handler.php" ## error-handler for status 404 #server.error-handler-404 = "/error-handler.html" #server.error-handler-404 = "/error-handler.php" ## Format: <errorfile-prefix><status-code>.html ## -> ..../status-404.html for 'File not found' #server.errorfile-prefix = "/srv/www/htdocs/errors/status-" include "conf.d/mime.conf" include "conf.d/dirlisting.conf" server.follow-symlink = "enable" #server.force-lowercase-filenames = "disable" server.upload-dirs = ( "/var/tmp" )modules.conf
## Modules to load ## ---------------- ## at least mod_access and mod_accesslog should be loaded ## all other module should only be loaded if really neccesary ## - saves some time ## - saves memory ## the default module set contains: server.modules = ( "mod_access", "mod_alias", "mod_auth", # "mod_authn_file", # "mod_evasive", # "mod_redirect", "mod_rewrite", "mod_cgi" # "mod_setenv", # "mod_usertrack", ) ## Config for various Module ## mod_geoip #include "conf.d/geoip.conf" ## mod_ssi #include "conf.d/ssi.conf" ## mod_status #include "conf.d/status.conf" ## mod_webdav #include "conf.d/webdav.conf" ## mod_compress #include "conf.d/compress.conf" ## mod_userdir #include "conf.d/userdir.conf" ## mod_magnet #include "conf.d/magnet.conf" ## mod_cml #include "conf.d/cml.conf" ## mod_rrdtool #include "conf.d/rrdtool.conf" ## mod_proxy #include "conf.d/proxy.conf" ## mod_expire #include "conf.d/expire.conf" ## mod_secdownload #include "conf.d/secdownload.conf" ## CGI modules ## SCGI (mod_scgi) #include "conf.d/scgi.conf" ## FastCGI (mod_fastcgi) #include "conf.d/fastcgi.conf" ## plain old CGI (mod_cgi) include "conf.d/cgi.conf" ## VHost Modules ## Only load ONE of them! ## ======================== ## You can use conditionals for vhosts aswell. ## see http://www.lighttpd.net/documentation/configuration.html ## mod_evhost #include "conf.d/evhost.conf" ## mod_simple_vhost #include "conf.d/simple_vhost.conf" ## mod_mysql_vhost #include "conf.d/mysql_vhost.conf" #######################################################################
cgi.conf File :-
server.modules += ( "mod_cgi" ) cgi.assign = ( ".pl" => "/usr/bin/perl", ".php" => "/usr/bin/php-cgi", ".cgi" => "/usr/bin/perl", ".rb" => "/usr/bin/ruby", ".erb" => "/usr/bin/eruby", ".py" => "/usr/bin/python" )
/var/log/lighttpd/error.log
2017-12-04 20:24:01: (log.c.217) server started 2017-12-04 21:11:39: (server.c.1828) server stopped by UID = 0 PID = 29168 2017-12-04 21:11:40: (log.c.217) server started 2017-12-04 21:17:59: (server.c.1828) server stopped by UID = 0 PID = 29207 2017-12-04 21:28:01: (log.c.217) server started 2017-12-04 21:40:31: (server.c.1828) server stopped by UID = 0 PID = 29359 2017-12-04 21:40:32: (log.c.217) server started 2017-12-04 21:50:33: (server.c.1828) server stopped by UID = 0 PID = 29411 2017-12-04 21:50:33: (log.c.217) server started 2017-12-04 21:56:15: (server.c.1828) server stopped by UID = 0 PID = 29441 2017-12-04 21:56:16: (log.c.217) server started 2017-12-04 21:57:10: (server.c.1828) server stopped by UID = 0 PID = 29478 2017-12-04 21:57:10: (log.c.217) server started 2017-12-04 21:57:23: (server.c.1828) server stopped by UID = 0 PID = 29513 2017-12-04 21:57:23: (log.c.217) server started 2017-12-04 22:09:50: (server.c.1828) server stopped by UID = 0 PID = 29652 2017-12-04 22:37:41: (log.c.217) server started 2017-12-04 22:37:41: (mod_compress.c.260) can't stat compress.cache-dir /var/cache/lighttpd/compress No such file or directory 2017-12-04 22:37:41: (server.c.1269) Configuration of plugins failed. Going down. 2017-12-04 22:37:46: (log.c.217) server started 2017-12-04 22:37:46: (mod_compress.c.260) can't stat compress.cache-dir /var/cache/lighttpd/compress No such file or directory 2017-12-04 22:37:46: (server.c.1269) Configuration of plugins failed. Going down. 2017-12-05 00:01:23: (log.c.217) server started 2017-12-05 00:05:40: (server.c.1828) server stopped by UID = 0 PID = 32378 2017-12-05 00:05:40: (log.c.217) server started 2017-12-05 00:08:13: (server.c.1828) server stopped by UID = 0 PID = 32418 2017-12-05 00:08:14: (log.c.217) server started 2017-12-05 00:10:10: (server.c.1828) server stopped by UID = 0 PID = 32452 2017-12-05 00:10:10: (log.c.217) server started 2017-12-06 11:18:36: (request.c.1289) POST-request, but content-length missing -> 411 2017-12-06 11:18:43: (request.c.1289) POST-request, but content-length missing -> 411 2017-12-06 11:19:32: (request.c.1289) POST-request, but content-length missing -> 411 2017-12-06 11:21:34: (request.c.1289) POST-request, but content-length missing -> 411 2017-12-06 11:23:57: (request.c.1289) POST-request, but content-length missing -> 411 2017-12-06 11:24:31: (request.c.1289) POST-request, but content-length missing -> 411 2017-12-06 11:26:02: (request.c.1289) POST-request, but content-length missing -> 411 2017-12-06 11:26:53: (request.c.1289) POST-request, but content-length missing -> 411 2017-12-06 11:27:04: (request.c.1289) POST-request, but content-length missing -> 411 2017-12-06 11:29:13: (request.c.1289) POST-request, but content-length missing -> 411 2017-12-06 11:35:04: (request.c.1289) POST-request, but content-length missing -> 411 2017-12-06 11:39:06: (server.c.1828) server stopped by UID = 0 PID = 11712 2017-12-06 11:39:07: (log.c.217) server started 2017-12-06 11:51:27: (server.c.1828) server stopped by UID = 0 PID = 11747 2017-12-06 11:51:28: (log.c.217) server started 2017-12-06 12:00:53: (server.c.1828) server stopped by UID = 0 PID = 11798 2017-12-06 12:00:54: (log.c.217) server started 2017-12-06 12:15:58: (request.c.1289) POST-request, but content-length missing -> 411 2017-12-06 12:30:31: (request.c.1289) POST-request, but content-length missing -> 411 2017-12-06 12:30:33: (request.c.1289) POST-request, but content-length missing -> 411 2017-12-06 12:30:50: (server.c.1828) server stopped by UID = 0 PID = 11855 2017-12-06 12:30:51: (log.c.217) server started 2017-12-06 12:30:57: (request.c.1289) POST-request, but content-length missing -> 411 2017-12-06 12:33:35: (server.c.1828) server stopped by UID = 0 PID = 11885 2017-12-06 12:33:36: (log.c.217) server started 2017-12-06 12:33:41: (request.c.1289) POST-request, but content-length missing -> 411 2017-12-06 12:48:28: (server.c.1828) server stopped by UID = 0 PID = 11919 2017-12-06 12:50:36: (log.c.217) server started 2017-12-06 12:50:44: (server.c.1828) server stopped by UID = 0 PID = 12022 2017-12-06 12:50:44: (log.c.217) server started 2017-12-06 12:50:53: (request.c.1289) POST-request, but content-length missing -> 411 2017-12-06 12:50:55: (request.c.1289) POST-request, but content-length missing -> 411 2017-12-06 12:51:03: (request.c.1289) POST-request, but content-length missing -> 411 2017-12-06 12:52:31: (request.c.1289) POST-request, but content-length missing -> 411 2017-12-06 12:53:05: (request.c.1289) POST-request, but content-length missing -> 411 2017-12-06 12:56:57: (request.c.1289) POST-request, but content-length missing -> 411 2017-12-06 13:01:42: (chunk.c.553) opening temp-file failed: Permission denied 2017-12-06 13:01:42: (mod_cgi.c.786) demuxer failed: 2017-12-06 13:11:30: (server.c.1828) server stopped by UID = 0 PID = 12089 2017-12-06 13:11:31: (log.c.217) server started 2017-12-06 13:17:00: (server.c.1828) server stopped by UID = 0 PID = 12123 2017-12-06 13:17:01: (log.c.217) server started 2017-12-06 13:19:08: (request.c.1289) POST-request, but content-length missing -> 411
Replies (3)
RE: [Solved] 411 - Length Required - Added by gstrauss over 7 years ago
411 - Length Required means exactly that. Please use your favorite search engine to look up HTTP status codes. If you are running an older version of lighttpd, then POST requests must provide Content-Length request header. Any HTTP/1.1 compliant client should be able to handle 411 Length Required. Additionally, newer versions of lighttpd support Transfer-Encoding: chunked for request body.
RE: [Solved] 411 - Length Required - Added by Koi8 over 7 years ago
I spent three days searching in Google and no solution for that , the problem are not in my script codes , since it work fine with nginx ,
I suspect that related to User that lighhtpd running under I change it to www-data and grant excess to important files
## /etc/lighttpd/lighttpd.conf server.username = "lighttpd" server.groupname = "lighttpd"
chown -R www-data:www-data /var/log/lighttpd/ chown -R www-data:www-data /var/www/ chmod -R 0755 /var/www/ chmod -R g+rwx /var/www/ chown -R www-data:www-data /var/tmp/ chmod -R 0755 /var/tmp/ chmod -R g+rwx /var/tmp/
but that didn't help I guess it due PHP-CGI uses root user by default if I run it via CLI ,
but I didn't know how lighttpd runs php in CGI mode is it use it same lighttpd user to start it or uses root !
cgi.assign = (".php" => "/usr/bin/php-cgi")
In nginx I face other problem after running PHP-cgi as service , that scripts like WP etc cant access to folders ,
so I run it on same web-server user
runuser -l www-data -c 'php-cgi -b 127.0.0.1:9000 &'
RE: [Solved] 411 - Length Required - Added by gstrauss over 7 years ago
I spent three days searching in Google and no solution for that
That's very funny; I don't believe you.
For all the information you have provided above, you have neglected to provide the version of lighttpd that you are running. Then again, I already told you that you're running an old version of lighttpd. Latest lighttpd is lighttpd 1.4.48.
Lastly, I promise that you're not the first person on the internet to run WP under lighttpd, so odds are the problem is not lighttpd, but how you are using it, along with your non-compliant client or script which does not properly handle 411 Length Required.