I have been working with this new language for a while and now I want to use juliar on Lighttpd there are no guides for that. However that there is a guide for Apache and Nginx. How do I configure my server for Lighttpd?
Unfortunately, Juliar doesn't officially support lighttpd.
However, you can do the following:
Open your lighttpd.conf file and add the following:
server.modules = (
"mod_fastcgi",
)
fastcgi.server += ( ".ju" =>
((
"host" => "127.0.0.1",
"port" => "9000",
"broken-scriptfilename" => "enable"
))
)
index-file.names=("index.ju","index.html")
Then just use "linuxspawn.sh" script and reload your lighttpd server.
Related
I got 2 server under same network and I hope to redirect domain.com/page to 192.168.2.16:22348 so i got this in lighttpd.conf according to this: lighttpd as reverse-proxy
$HTTP["url"] =~ "^/page" {
proxy.server = ( "" => ( ( "host" => "192.168.2.16", "port" => 22348 ) ) )
}
but I ended up getting redirected to 192.168.2.16/maps which doesn't exist (I only got index.html but I can't change it) and returned 404.
Is there any way to only pass IP and port but not /page?
(I also tried domain.com/google to google.com by the same way but ended up to google.com/google)
Others I also tried:
https://redmine.lighttpd.net/projects/1/wiki/Docs_ModProxy
Others I also tried: https://redmine.lighttpd.net/projects/1/wiki/Docs_ModProxy
I think you should look at proxy.header "map-urlpath" on the same page.
So instead of using www.domain.com/page, i decided to use subdomain.domain.com.
Here's what I got.
$HTTP["host"] =~ "subdomain.domain.com" {
proxy.server = ( "" => ( ( "host" => "192.168.2.16", "port" => "22348" ) ) )
}
Since there is nothing after subdomain.domain.com/, it won't pass anything but only ip and port (192.168.2.16:22348) so I don't need to modify anything from the second machine. I think this is easier to configure instead of using /page.
I'm trying to set up the Perl Catalyst plugin Catalyst:: Plugin:: RunAfterRequest and am seeing different behaviour when it is being run with the server script "APPNAME/script/APPNAME_server.pl" and the FastCGI process under Lighttpd.
That is, it works as expected with the server script, but when used in the FastCGI web server environment the request being returned seems to be blocked by the code allegedly running after the request is returned. This is easily reproducible with the code in Controller/Root.pm:
sub index : Private {
my ($self, $c) = #_;
$c->run_after_request(
sub {sleep 10;}
);
$c->response->body("foobar");
}
Running the test script returns a result instantaneously as expected, but will wait 10 seconds before a response in the web server environment.
Is there any configuration that needs to be made with Lighttpd or FastCGI to get this to work properly?
UPDATE:
As requested, sample lighttpd config:
include "common/mime.conf"
include "common/modules-core.conf"
server.bind = "127.0.0.1"
server.port = 6080
server.pid-file = "/path/to/lighttpd-6080.pid"
server.username = "user"
server.groupname = "group"
server.document-root = "/path/to/root"
server.errorlog = "/path/to/.errors-6080"
accesslog.filename = "/path/to/.access-6080"
include "common/index.conf"
server.modules += ( "mod_fastcgi")
server.stream-response-body = 2
$HTTP["url"] !~ "^/(?:img/|static/|css/|favicon.ico$)" {
fastcgi.server = (
"" => (
"appname" => (
"socket" => "/path/to/appname-fcgi.sock",
"check-local" => "disable",
"bin-path" => "/path/to/appname_fastcgi.pl",
"min-procs" => 2,
"max-procs" => 5,
"idle-timeout" => 20
)
)
)
}
Last time I was using Apache2+PHP5 as my web server and it run normally unless too slow when server is process my script and I had change it to lighttpd + fastcgi. It faster than and low memory usage.
My problem is when lighttpd running some time it "No input file specified." but some time is ok. But when I restart lighttpd every come to normally.
I don't know why and how to solve it.
This is my config.
$SERVER["socket"] == ":80" {
$HTTP["host"] == "xxx.xxx.xxx.xxx" {
server.document-root = "/var/www/public_html"
server.errorlog = "/var/www/public_html/logs/error.log"
accesslog.filename = "/var/www/public_html/logs/access.log"
compress.cache-dir = "/var/www/public_html/cache"
}
$HTTP["host"] == "sub.domain.com" {
server.document-root = "/var/www/public_html"
server.errorlog = "/var/www/public_html/logs/error.log"
accesslog.filename = "/var/www/public_html/logs/access.log",
compress.cache-dir = "/var/www/public_html/cache"
}
index-file.names = ( "index.php", "index.html", "index.htm", "default.htm" )
url.rewrite-if-not-file = (
"^/image(.*)" => "/image-api.php$1",
"^/go/([a-zA-Z0-9_-]+)" => "/index.php?go=$1",
"^/oembed(.*)" => "/oembed_provider/index.php$1",
"^/player$" => "/library/plugin/video-player/player.swf",
"^/v(.*)" => "/cvd.php$1",
"^/me" => "/user.php",
"^/#(.*)\?(.*)" => "/profile.php?indentity=$1&$2",
"^/#(.*)" => "/profile.php?indentity=$1",
"^/url?g=(.*)" => "/url.php?g=$1",
"^/social_auth/(.*)" => "/partner_api/$1.php",
"^/c/(.*)" => "/view.php?view=$1",
"^/u/(.*)" => "/profile.php?indentity=$1",
"^/project/(.*)" => "/section.php?page=$1",
"^/min/(.*)" => "/mini/index.php$1",
"^/src/(.*)" => "/src/$1",
"^/library/(.*)" => "/library/$1",
"^/\?(.*)" => "/index.php?$1",
"^/(.*)\?(.*)" => "/page.php?p=$1&$2",
"^/(.*)" => "/page.php?p=$1"
)
$HTTP["host"] == "domain.org" {
url.redirect = ("/(.*)$" => "https://domain.com/$1")
}
$HTTP["host"] == "domain.info" {
url.redirect = ("/(.*)$" => "https://domain.com/$1")
}
$HTTP["host"] == "domain.net" {
url.redirect = ("/(.*)$" => "https://domain.com/$1")
}
}
From the FAQ, it looks like there are several possibilities:
I get the error "No input file specified" when trying to use PHP
Sadly, this error message can mean a lot of things.
A common explanation attempt: PHP is unable to locate or open the file which it
is supposed to parse.
This can have a lot of reasons:
You forgot to
add ''cgi.fix_pathinfo=1 to your php.ini'' file. See the comments in
the PHP docs. The issue here is that the environment variable
SCRIPT_FILENAME is not being passed to PHP.
Make sure you did not set
doc_root or userdir in php.ini, or if you have set it, make sure it
has the correct value (doc_root should match lighttpd's
server.document-root option in this case)
If open_basedir is set, make
sure the requested file is below one of the directories which is
specified there. In the past PHP parsed files which were not inside
open_basedir as well, but this security problem was fixed (in
php-5.2.3 or so).
If you are running PHP with different permissions
than lighttpd (spawn-fcgi with -u/-g, execwrap, suexec, ...), check
that PHP can really read the file
If you are unable to find / fix the
problem, you can use strace to see if it is a (OS-related) permission
problem (look out for stat*(...YOURFILE...) = RETURNCODE). It might
help to set max-procs to 1 and PHP_FCGI_CHILDREN as well (see fastcgi
docs) in that case, so that you can easily attach strace to the
correct php-cgi process.
I am trying to connect to github using Net::GitHub
my code is something like the below :
use Net::GitHub::V3;
my $gh = Net::GitHub::V3->new(
login => 'myuser', pass => 'mypassword'
);
my $search = $gh->search;
my %data = $search->repositories({ q => 'repname' });
i get the following error message :
Can't connect to api.github.com:443 at Net/GitHub/V3/Search.pm line 27.
worth to mention i am using this mdoule behind a proxy
do someone familiar how to solve this issue ?
I just uploaded a new version of Net::GitHub to CPAN. 0.69.
now you can do something like
$gh->ua->proxy('https', 'socks://127.0.0.1:9050');
check examples/proxy.pl $gh->ua is LWP::UserAgent.
Thanks
I am trying to write a Perl script to connect to me YouTube account but it doesnt seem to work. Basically I just want to connect to my account but apparently it is not working. I don't even have an idea on how I could debug this! Maybe it is something related to https protocol?
Please enlighten me! Thanks in advance.
use HTTP::Request::Common;
use LWP::UserAgent;
use strict;
my $login="test";
my $pass = "test";
my $res = "";
my $ua = "";
# Create user agent, make it look like FireFox and store cookies
$ua = LWP::UserAgent->new;
$ua->agent("Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20051213 Firefox/1.0.7");
$ua->cookie_jar ( {} );
# Request login page
$res = $ua->request(GET "https://www.google.com/accounts/ServiceLogin?service=youtube&hl=en_US&passive=true<mpl=sso&uilel=3&continue=http%3A//www.youtube.com/signup%3Fhl%3Den_US%26warned%3D%26nomobiletemp%3D1%26next%3D/index");
die("ERROR1: GET http://www.youtube.com/login\n") unless ($res->is_success);
# Now we login with our user/pass
$res = $ua->request(
POST "https://www.google.com/accounts/ServiceLoginAuth?service=youtube",
Referer => "http://www.youtube.com/login",
Content_Type => "application/x-www-form-urlencoded",
Content => [
currentform => "login",
next => "/index",
username => $login,
password => $pass,
action_login => "Log+In"
]
);
# YouTube redirects (302) to a new page when login is success
# and returns OK (200) if the login failed.
#die("ERROR: Login Failed\n") unless ($res->is_redirect());
print $res->content;
what i am doing is learning the web features of perl, so i dont want to use any library except wwwlib or mechanize to get the job done.
how can i just connect to my account using a perl script? this is my objective for now
hope someone can post a script or correct mine.
thank you guys for you help.
i am testing Webscarab now..
What data are you trying to grab? Why not just using an existing implementation like WebService::YouTube
Some comments on your code: I always avoided the shortcut $ua->request(GET/POST) method since I always ended up needing more flexibility that only the use of HTTP::Request and HTTP::Response allowed. I always felt the code was cleaner that way too.
Why is your code not working? Who knows.
Make sure your cookiejar is adding your cookies to the outgoing HTTP::Request. I'd suggest dumping all your headers when you do it in a browser and compare with the headers and data that libwww is sending. There may be some additional fields that they are checking for that vary for every hit. They may be checking for your UserAgent string. If you are just looking to learn libwww I'd suggest using a different site as a target as I'm sure YouTube has all sort of anti-scripting hardening.
Are you using YouTube's stable documented API?
Use an HTTP proxy such as WebScarab to watch the data flow.
Trey's suggestion to use somebody else's CPAN package for the mechanics is a good idea too.
Right right by and large, what you want to do is define a cookiejar for most of these websites that have a redirection login. This is what the package has done. Also the package tunes a lot of the lookups and scrapes based on the youtube spec.
Ajax content for example will be rough since its not there when your scraping
You just picked a somewhat rough page to start out with.
Enjoy
I'm actually working on this issue myself. Before, I would suggest read over this the API guide from Google as a good starting reference. If I'm reading it correctly, one begins with passing user credentials through a REST interface to get a Authentication Token. To handle that, I'm using the following:
sub getToken {
my %parms = #_;
my $response = LWP::UserAgent->new->post(
'https://www.google.com/youtube/accounts/ClientLogin',
[
Email => $parms{'username'},
Passwd => $parms{'password'},
service => "youtube",
source => "<<Your Value Here>>",
]
);
my $content = $response->content;
my ($auth) = $content =~ /^Auth=(.*)YouTubeUser(.*)$/msg
or die "Unable to authenticate?\n";
my ($user) = $content =~ /YouTubeUser=(.*)$/msg
or die "Could not extract user name from response string. ";
return ($auth, $user);
}
And I call that from the main part of my program as such:
## Get $AuthToken
my ($AuthToken, $GoogleUserName) = getToken((
username => $email, password => $password
));
Once I have these two things -- $AuthToken and $GoogleUserName, I'm still testing the LWP Post. I'm still writing this unit:
sub test {
my %parms = #_;
## Copy file contents. Use, foy's three param open method.
my $fileSize = -s $parms{'File'};
open(VideoFile, '<', "$parms{'File'}") or die "Can't open $parms{'File'}.";
binmode VideoFile;
read(VideoFile, my $fileContents, $fileSize) or die "Can't read $parms{'File'}";
close VideoFile;
my $r = LWP::UserAgent->new->post(
"http://uploads.gdata.youtube.com/feeds/api/users/$parms{'user'}/uploads",
[
Host => "uploads.gdata.youtube.com",
'Authorization' => "AuthSub token=\"$parms{'auth'}\"",
'GData-Version' => "2",
'X-GData-Key' => "key=$YouTubeDeveloperKey",
'Slug' => "$parms{'File'}",
'Content-Type' => "multipart/related; boundary=\"<boundary_string>\"",
'Content-Length' => "<content_length>",
'video_content_type'=> "video/wmv",
'Connection' => "close",
'Content' => $fileContents
]
);
print Dumper(\$r->content)
}
And that is called as
&test((auth=>$Auth, user=>$user, File=>'test.wmv'));