Alessio Rocchi's Blog
Just another geek’s blog
Just another geek’s blog
Jul 15th
Visto che a lavoro mi son trovato a dover scrivere 2 appunti su come ho configurato un server Apache, ho deciso di riportarlo anche sul mio blog, magari fa comodo a qualcuno
Apache2 + mod_ssl + htaccess + virtual hosts
Per aggiungere un nuovo virtual host basta fare i seguenti passi:
1 – Creare un file in /etc/apache2/site-available
2 – Popolarlo con la configurazione corretta sia sulla porta 80 che sulla 443 se necessario SSL
3 – Abilitarlo tramite il comando a2ensite [file di configurazione]
4 – Fare il reload di Apache2:
/etc/init.d/apache2 reload
Se non ci sono errori, il nuovo virtual host e` attivo.
Le configurazioni di Apache si trovano nella directory /etc/apache2, i virtual host creati risiedono in /etc/apache2/site-available e sono stati abilitati tramite in comando a2ensite
a2ensite wiki.trii.it
Di conseguenza sono attivi in /etc/apache2/site-enabled
Utilizziamo un sistema di accessi tramite htaccess che risiede in /var/www/wiki.trii.it/.htaccess, mentre il file dell pwd sta in /var/www/.htpasswd
Per aggiungere un utente basta utilizzare htpasswd nel seguente modo:
htpasswd /var/www/.htpasswd nuovoutente
Verra` chiesta due volte la password ed il gioco e` fatto.
La configurazione e` di tipo SSL, di seguito riportata
#Questo primo blocco server per fare redirect da http ad https nel caso in cui si tenti di accedere al wiki via http
<VirtualHost *:80>
ServerName wiki.trii.it
RedirectMatch (.*)$ https://wiki.trii.it$1
RedirectMatch /.* https://wiki.trii.it
</VirtualHost>
#Questo e` il blocco principale della configurazione, ho lasciato il blocco dei cgi-bin anche se in realta` non li usiamo.
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile /etc/apache2/apache.pem
ServerAdmin alessio.rocchi@trii.it
ServerName wiki.trii.it
ServerAlias wiki
DocumentRoot /var/www/wiki.trii.it
Options FollowSymLinks
AllowOverride AuthConfig
Order allow,deny
allow from all
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
May 11th
Hi, this plugin allow your X-Chat client to reflex any DCC SEND like mIRC does. We have created this plugin, due to the high number of people that has requested us a plugin to reflex from X-Chat.
Also, my friend Xardax has the idea to make a plugin for KvIRC too, so be patient ![]()
If yuo have any doubts you can contact us on IRC: irc.darksin.ch :: #linux
#!/usr/bin/perl
use warnings;
use strict;
use Xchat;
my $reflex_nick="";
Xchat::register("Reflexer","1.0","Reflexer Perl Script","");
Xchat::print ("^BScript loaded.");
Xchat::print ("^BPlugin for X-Chat by blackms & Xardax :: #linux \@irc.darksin.ch");
Xchat::print ("^BUsage: /reflex REFLEX_NICK\n^BTo turn reflexing off: /rfx_off");
Xchat::hook_command('reflex',"reflex");
Xchat::hook_command('rfx_off',sub {
Xchat::print ("^BReflexing turned off.");
$reflex_nick="";
}
);
Xchat::hook_server("PRIVMSG","ctcpreflex");
sub reflex {
$reflex_nick = defined $_[0][1] ? $_[0][1] : "";
Xchat::print("^BReflexing all DCC SEND to: $reflex_nick");
return Xchat::EAT_ALL;
}
sub ctcpreflex {
return Xchat::EAT_NONE if ($reflex_nick eq "");
my $data=$_[1][0];
if ($data =~ m{\001DCC\sSEND\s(.*)\s(\d+)\s(\d+)\s(\d+)\001}) {
my ($file,$intip,$port,$length) = ($1,$2,$3,$4);
Xchat::print ("^BReflexing: $file to $reflex_nick on port: $port, length: $length");
Xchat::command ("PRIVMSG $reflex_nick :\001DCC SEND $file $intip $port $length\001\n\r");
return Xchat::EAT_ALL;
}
return Xchat::EAT_NONE;
}
Bye
Apr 19th
I’ve made this to stress this blog a little, and see how many requests could it handle.
#!/usr/bin/perl
use strict;
use LWP::Simple;
use LWP::UserAgent;
use Parallel::ForkManager;
my $pm = new Parallel::ForkManager(3);
for (1 .. 10_000) {
my $pid = $pm->start and next;
my $ua = new LWP::UserAgent;
print "Request $_\n";
$ua->timeout(120);
my $url='http://www.rocchi.us/';
my $request = new HTTP::Request('GET', $url);
my $response = $ua->request($request);
my $content = $response->content();
#print $content;
$pm->finish;
}
Bye