<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Naeh.net</title>
	
	<link>http://naeh.net</link>
	<description>Le mémo du développeur</description>
	<lastBuildDate>Sun, 07 Aug 2011 20:29:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Naeh" /><feedburner:info uri="naeh" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>upload avec barre de progression</title>
		<link>http://feedproxy.google.com/~r/Naeh/~3/z4H95KxdGcQ/</link>
		<comments>http://naeh.net/upload-avec-barre-de-progression/#comments</comments>
		<pubDate>Sun, 07 Aug 2011 20:29:39 +0000</pubDate>
		<dc:creator>Naeh</dc:creator>
				<category><![CDATA[Linux - Logiciels]]></category>
		<category><![CDATA[PHP / MySQL]]></category>
		<category><![CDATA[Programmation]]></category>

		<guid isPermaLink="false">http://naeh.net/?p=213</guid>
		<description><![CDATA[dans cet article-tuto nous allons voir comment mettre en place un système d'upload avec une sympathique barre de progression. les pré-requis : - un serveur web Apache - PHP5 avec l'extension APC - jquery dans ce tuto je pars du principe qu'Apache et PHP sont installés et fonctionnels, on va juste voir comment installer APC [...]]]></description>
			<content:encoded><![CDATA[<p>dans cet article-tuto nous allons voir comment mettre en place un système d'upload avec une sympathique barre de progression.</p>
<p>les pré-requis :<br />
- un serveur web Apache<br />
- PHP5 avec l'extension APC<br />
- <a href="http://jquery.com/" target="_blank">jquery</a></p>
<p>dans ce tuto je pars du principe qu'Apache et PHP sont installés et fonctionnels, on va juste voir comment installer APC et activer le suivi de la progression d'upload :</p>

<div class="wp_codebox"><table><tr id="p2138"><td class="code" id="p213code8"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> php-apc
<span style="color: #c20cb9; font-weight: bold;">vim</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php5<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>conf.d<span style="color: #000000; font-weight: bold;">/</span>apc.ini</pre></td></tr></table></div>

<p>ajouter à la fin du fichier :</p>

<div class="wp_codebox"><table><tr id="p2139"><td class="code" id="p213code9"><pre class="text" style="font-family:monospace;">apc.rfc1867 = on</pre></td></tr></table></div>

<p>cette ligne magique, activera la suivi de progression d'upload sur le serveur.</p>
<p>on reload apache :</p>

<div class="wp_codebox"><table><tr id="p21310"><td class="code" id="p213code10"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>apache2 reload</pre></td></tr></table></div>

<p>le coté système de la chose est maintenant terminé, passons à l'upload :</p>
<p>pour la petite histoire, voici ce que l'on va faire :<br />
on va créer un formulaire, qui sera validé vers (target) une iframe invisible, le temps que l'upload se passe, on va contacter un petit script php en ajax (très souvent) qui va nous dire où en est l'upload, en nous retournant le pourcentage d'avancement (tout simplement), avec cette valeur, on va pouvoir mettre en place une barre de progression très facilement.</p>
<p>pour commencer, le formulaire :</p>

<div class="wp_codebox"><table><tr id="p21311"><td class="code" id="p213code11"><pre class="html" style="font-family:monospace;">&lt;?php $unique_id = uniqid(); //id unique de notre formulaire ?&gt;
&nbsp;
&lt;!-- iframe caché en javascript dans laquelle se fait l'upload, elle affichera le message de confirmation / ou erreur à la fin de l'upload --&gt;
&lt;iframe frameborder=&quot;0&quot; border=&quot;0&quot; id=&quot;upload_to&quot; name=&quot;upload_to&quot; style=&quot;width: 100%; border:none; border-color: #fff;&quot; scrolling=&quot;no&quot;&gt;&lt;/iframe&gt;
&nbsp;
&lt;!-- le formulaire d'upload --&gt;
&lt;form id=&quot;upload_form&quot; enctype=&quot;multipart/form-data&quot; action=&quot;upload.php&quot; method=&quot;post&quot; target=&quot;upload_to&quot;&gt;
&lt;input type=&quot;hidden&quot; name=&quot;APC_UPLOAD_PROGRESS&quot; id=&quot;progress_key&quot; value=&quot;&lt;?php echo $unique_id?&gt;&quot;/&gt;
&lt;div id=&quot;progressouter&quot;&gt;
	&lt;div id=&quot;progressinner&quot;&gt;&lt;span id=&quot;progression_percent&quot;&gt;0&amp;nbsp;%&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;input id=&quot;file&quot; type=&quot;file&quot; name=&quot;file&quot; size=&quot;30&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;input type=&quot;submit&quot; value=&quot;valider&quot; /&gt;&lt;/p&gt;
&lt;/form&gt;</pre></td></tr></table></div>

<p>le bout de php au début, permet de donner un id unique au formulaire<br />
il est renseigné dans le champ "<strong>APC_UPLOAD_PROGRESS</strong>" ceci permet au système de donner un id à l'upload en cours, ce qui nous permettra de consulter la progression en le connaissant (l'id).</p>
<p>l'iframe n'a rien de spéciale, elle est caché en javascript (voir plus bas).</p>
<p>le formulaire contient l'HTML de la barre de progression (la div <strong>progressouter</strong>, on pourrait la mettre ailleurs, chacun fait ce qu'il veut. et le champ hidden <strong>APC_UPLOAD_PROGRESS</strong> comme dit plus haut, obligatoire pour le suivi de l'upload.</p>
<p>passons maintenant à notre script d'upload : <strong>upload.php</strong><br />
l'upload en lui même n'est pas vraiment notre sujet du jour, donc, je prends l'exemple d'upload le plus simple au monde (donné sur <a href="http://php.net" target="_blank">php.net</a>)</p>

<div class="wp_codebox"><table><tr id="p21312"><td class="code" id="p213code12"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$uploaddir</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/var/www/uploads/'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$uploadfile</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$uploaddir</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/basename"><span style="color: #990000;">basename</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'file'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/move_uploaded_file"><span style="color: #990000;">move_uploaded_file</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'file'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'tmp_name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$uploadfile</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;File is valid, and was successfully uploaded.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Possible file upload attack!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>on aura besoin du fameux script qui retourne le pourcentage d'avancement de l'upload : <strong>progress.php</strong></p>

<div class="wp_codebox"><table><tr id="p21313"><td class="code" id="p213code13"><pre class="php" style="font-family:monospace;"><a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Cache-Control: no-cache&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//utile pour IE (problème avec l'ajax)</span>
<span style="color: #666666; font-style: italic;">//progression</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'progress_key'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$upload</span> <span style="color: #339933;">=</span> apc_fetch<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'upload_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'progress_key'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$percent</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1000</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$upload</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$upload</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'done'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #000088;">$percent</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$upload</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'total'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
            <span style="color: #000088;">$percent</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">else</span>
            <span style="color: #000088;">$percent</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$upload</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'current'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">/</span> <span style="color: #000088;">$upload</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'total'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">echo</span> <a href="http://www.php.net/number_format"><span style="color: #990000;">number_format</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$percent</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>c'est presque fini, il ne reste plus que le javascript :</p>

<div class="wp_codebox"><table><tr id="p21314"><td class="code" id="p213code14"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> getProgress<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> count <span style="color: #339933;">=</span> Math.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">/// Math.random sélectionne un nombre entre 0 et 1 ( ex: 0.6489534931546957) pour IE aussi (même si le header no-cache devrait suffire)</span>
    $.<span style="color: #660066;">ajax</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
        type<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;GET&quot;</span><span style="color: #339933;">,</span>
        url<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;/progress.php?progress_key=&lt;?php echo($unique_id)?&gt;&amp;count=&quot;</span><span style="color: #339933;">+</span>count<span style="color: #339933;">,</span>
        success<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>percent<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>percent <span style="color: #339933;">&lt;=</span> <span style="color: #CC0000;">100</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#progressinner&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;width&quot;</span><span style="color: #339933;">,</span> percent<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;%&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#progression_percent&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span>percent<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot; %&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>percent <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">100</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                setTimeout<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;getProgress()&quot;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>percent <span style="color: #339933;">==</span> <span style="color: #CC0000;">100</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#upload_to&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;slow&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#file&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> startProgress<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#progressouter, #progression_percent&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">200</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    setTimeout<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;getProgress()&quot;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#upload_to&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#upload_form'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">submit</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        startProgress<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>en gros (très gros même) ce js va cacher l'iframe au chargement de la page, et à la validation du formulaire, il va lancer la fonction startProgress(), qui elle, va afficher la barre de progression et lancer régulièrement getProgress, qui elle, fait un appel ajax à notre script progress.php et lui indiquant l'unique id généré tout au début de la page et en fonction du retour, elle va ajuster la largeur de la barre de progression.</p>
<p>si vous avez des questions, n'hésitez pas à les poser dans les commentaires.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fnaeh.net%2Fupload-avec-barre-de-progression%2F&amp;title=upload%20avec%20barre%20de%20progression" id="wpa2a_2"><img src="http://naeh.net/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><img src="http://feeds.feedburner.com/~r/Naeh/~4/z4H95KxdGcQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://naeh.net/upload-avec-barre-de-progression/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://naeh.net/upload-avec-barre-de-progression/</feedburner:origLink></item>
		<item>
		<title>Sécuriser un serveur MySQL avec iptables</title>
		<link>http://feedproxy.google.com/~r/Naeh/~3/UZHuoGfQ90o/</link>
		<comments>http://naeh.net/securiser-un-serveur-mysql-avec-iptables/#comments</comments>
		<pubDate>Mon, 01 Aug 2011 18:40:18 +0000</pubDate>
		<dc:creator>Naeh</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Linux - Logiciels]]></category>
		<category><![CDATA[Linux - OS]]></category>
		<category><![CDATA[firewal]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[phpmyadmin]]></category>

		<guid isPermaLink="false">http://naeh.net/?p=211</guid>
		<description><![CDATA[quand on a plusieurs serveurs avec un mysql sur chacun, on aimerait parfois avoir un seul phpmyadmin dans lequel tous les serveurs mysql remontent, la solution est très simple, il suffit d'aller dans /etc/mysql/my.cnf et de commenter la ligne : bind-address = 127.0.0.1 en ajoutant un # devant. ça s'applique aussi quand on a un [...]]]></description>
			<content:encoded><![CDATA[<p>quand on a plusieurs serveurs avec un mysql sur chacun, on aimerait parfois avoir un seul phpmyadmin dans lequel tous les serveurs mysql remontent, la solution est très simple, il suffit d'aller dans /etc/mysql/my.cnf et de commenter la ligne :</p>

<div class="wp_codebox"><table><tr id="p21117"><td class="code" id="p211code17"><pre class="bash" style="font-family:monospace;">bind-address           = 127.0.0.1</pre></td></tr></table></div>

<p>en ajoutant un # devant.</p>
<p>ça s'applique aussi quand on a un seul serveur mysql accessible par plusieurs serveurs web par exemple.</p>
<p>en faisant cela, on vient d'autoriser les connexions au serveur depuis... <strong>partout</strong> ! (alors que par défaut il ne les accepte que depuis localhost) ce qui va nous permettre d'avoir un phpmyadmin unique pour pleins de serveurs mysql.</p>
<p>le problème, c'est qu'en terme de sécurité, la règle est simple, "<strong>Je ferme tout, puis j'ouvre ce dont j'ai besoin</strong>"<br />
ici le besoin est d'ouvrir l'accès à Mysql depuis le serveur qui héberge phpmyadmin, or, avec notre modification, on vient d'ouvrir l'accès à tout le monde (encore faut-il avoir des login/password valides pour se connecter, mais vaut mieux ne pas tenter le diable^^).</p>
<p>pour remédier au problème, on va avoir recours au <strong>firewall</strong>, sous debain (et linux en général) c'est <strong>iptables</strong></p>
<p>on va explicitement permettre l'accès à notre mysql depuis le serveur hébergeant phpmyadmin, et... le refuser à tout le reste</p>

<div class="wp_codebox"><table><tr id="p21118"><td class="code" id="p211code18"><pre class="bash" style="font-family:monospace;">iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-s</span> IP_DU_SERVEUR_PHPMYADMIN <span style="color: #660033;">--dport</span> <span style="color: #000000;">3306</span> <span style="color: #660033;">-j</span> ACCEPT
iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">3306</span> <span style="color: #660033;">-j</span> DROP</pre></td></tr></table></div>

<p>et voilà, en 2 lignes c'est fait.<br />
la première autorise le serveur qui héberge phpmyadmin, la 2ème ferme tout.</p>
<p>il est à noter que ces règles seront perdues si le serveur redémarre, donc, si redémarrage, il faudra les retaper, ou sinon les mettre dans un script exécuté au démarrage, comment faire ? c'est le sujet d'un prochain post <img src='http://naeh.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fnaeh.net%2Fsecuriser-un-serveur-mysql-avec-iptables%2F&amp;title=S%C3%A9curiser%20un%20serveur%20MySQL%20avec%20iptables" id="wpa2a_4"><img src="http://naeh.net/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><img src="http://feeds.feedburner.com/~r/Naeh/~4/UZHuoGfQ90o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://naeh.net/securiser-un-serveur-mysql-avec-iptables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://naeh.net/securiser-un-serveur-mysql-avec-iptables/</feedburner:origLink></item>
		<item>
		<title>Changer le hostname d’un serveur sous debian</title>
		<link>http://feedproxy.google.com/~r/Naeh/~3/GZJMT0Sv9f8/</link>
		<comments>http://naeh.net/changer-le-hostname-dun-serveur-sous-debian/#comments</comments>
		<pubDate>Thu, 28 Jul 2011 12:03:38 +0000</pubDate>
		<dc:creator>Naeh</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Linux - OS]]></category>

		<guid isPermaLink="false">http://naeh.net/?p=205</guid>
		<description><![CDATA[ayant pris possession d'un petit kimsufi récemment je me suis dit qu'il serait bien de changer ksXXYYZZ par un hostname qui me parle un peu plus , donc, si comme moi, un jour vous voulez changer le hostname d'un serveur, voici ce qu'il faut faire : changer le ici mettant le nouveau hostname : vim [...]]]></description>
			<content:encoded><![CDATA[<p>ayant pris possession d'un petit kimsufi récemment je me suis dit qu'il serait bien de changer ksXXYYZZ par un hostname qui me parle un peu plus <img src='http://naeh.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> , donc, si comme moi, un jour vous voulez changer le hostname d'un serveur, voici ce qu'il faut faire :</p>
<p>changer le ici mettant le nouveau hostname :</p>

<div class="wp_codebox"><table><tr id="p20523"><td class="code" id="p205code23"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">vim</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">hostname</span></pre></td></tr></table></div>

<p>ensuite ouvrez le fichier hosts et AJOUTER (dans le cas du kimsufi, il faut qu'il réponde toujours au nom ksXXYYZZ donc ne remplacez pas, mais ajouter) le nouveau hostname (en face des ip locales)</p>

<div class="wp_codebox"><table><tr id="p20524"><td class="code" id="p205code24"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>hosts</pre></td></tr></table></div>

<p>ce qui donne (par exemple):</p>

<div class="wp_codebox"><table><tr id="p20525"><td class="code" id="p205code25"><pre class="txt" style="font-family:monospace;">127.0.0.1       localhost.localdomain localhost
WW.XX.YY.YY     ksXXYYZZ.kimsufi.com monNouveauHostname</pre></td></tr></table></div>

<p>rendre la modification effective :</p>

<div class="wp_codebox"><table><tr id="p20526"><td class="code" id="p205code26"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>hostname.sh start</pre></td></tr></table></div>

<p>et c'est tout <img src='http://naeh.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> , il faut se déconnecter/reconnecter pour voir le changement.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fnaeh.net%2Fchanger-le-hostname-dun-serveur-sous-debian%2F&amp;title=Changer%20le%20hostname%20d%26%238217%3Bun%20serveur%20sous%20debian" id="wpa2a_6"><img src="http://naeh.net/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><img src="http://feeds.feedburner.com/~r/Naeh/~4/GZJMT0Sv9f8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://naeh.net/changer-le-hostname-dun-serveur-sous-debian/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://naeh.net/changer-le-hostname-dun-serveur-sous-debian/</feedburner:origLink></item>
		<item>
		<title>installer memcached sous debian lenny</title>
		<link>http://feedproxy.google.com/~r/Naeh/~3/OwwfvrQfCq8/</link>
		<comments>http://naeh.net/installer-memcached-sous-debian-lenny/#comments</comments>
		<pubDate>Tue, 26 Jul 2011 13:40:59 +0000</pubDate>
		<dc:creator>Naeh</dc:creator>
				<category><![CDATA[Divers]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Linux - Logiciels]]></category>

		<guid isPermaLink="false">http://naeh.net/?p=198</guid>
		<description><![CDATA[avec ce post nous allons voir la procédure pour installer memcache sur une debian lenny afin de l'utiliser avec php. Pour commencer installer memcached : apt-get install memcached ensuite, installer l'extension php pecl install memcache si l'installation échoue avec le message suivant : downloading memcache-2.2.6.tgz ... Starting to download memcache-2.2.6.tgz &#40;35,957 bytes&#41; ..........done: 35,957 bytes [...]]]></description>
			<content:encoded><![CDATA[<p>avec ce post nous allons voir la procédure pour installer memcache sur une debian lenny afin de l'utiliser avec php.</p>
<p>Pour commencer installer memcached :</p>

<div class="wp_codebox"><table><tr id="p19834"><td class="code" id="p198code34"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> memcached</pre></td></tr></table></div>

<p>ensuite, installer l'extension php</p>

<div class="wp_codebox"><table><tr id="p19835"><td class="code" id="p198code35"><pre class="bash" style="font-family:monospace;">pecl <span style="color: #c20cb9; font-weight: bold;">install</span> memcache</pre></td></tr></table></div>

<p>si l'installation échoue avec le message suivant :</p>

<div class="wp_codebox"><table><tr id="p19836"><td class="code" id="p198code36"><pre class="bash" style="font-family:monospace;">downloading memcache-2.2.6.tgz ...
Starting to download memcache-2.2.6.tgz <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">35</span>,<span style="color: #000000;">957</span> bytes<span style="color: #7a0874; font-weight: bold;">&#41;</span>
..........done: <span style="color: #000000;">35</span>,<span style="color: #000000;">957</span> bytes
<span style="color: #000000;">11</span> <span style="color: #7a0874; font-weight: bold;">source</span> files, building
running: phpize
<span style="color: #c20cb9; font-weight: bold;">sh</span>: phpize: <span style="color: #7a0874; font-weight: bold;">command</span> not found
ERROR: <span style="color: #000000; font-weight: bold;">`</span>phpize<span style="color: #ff0000;">' failed</span></pre></td></tr></table></div>

<p>Allez faire un tour ici : <a href="http://naeh.net/installation-fileinfo/" title="Installation de fileinfo" target="_blank">Installation de fileinfo</a> on a déjà rencontré ce problème <img src='http://naeh.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Pour rappel, il faut faire un simple :</p>

<div class="wp_codebox"><table><tr id="p19837"><td class="code" id="p198code37"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> php5-dev
et retenter le :
pecl <span style="color: #c20cb9; font-weight: bold;">install</span> memcache</pre></td></tr></table></div>

<p>il va surement vous poser une question, appuyez sur « entrée »</p>
<p>maintenant que memcache est correctement installer il faut l'activer en créant un fichier memcached.ini dans le dossier conf.d utilisé par le serveur (dans mon cas pour apache c'est : /etc/php5/apache2/conf.d) pour lighttpd par exemple c'est /etc/php5/cgi/conf.d) (cela évite de modifier les php.ini)<br />
memcached.ini doit contenir :</p>

<div class="wp_codebox"><table><tr id="p19838"><td class="code" id="p198code38"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">extension</span>=memcache.so</pre></td></tr></table></div>

<p>pour s'assurer que l'extension est bien installée, créer un fichier php contenant :</p>

<div class="wp_codebox"><table><tr id="p19839"><td class="code" id="p198code39"><pre class="php" style="font-family:monospace;"><a href="http://www.php.net/phpinfo"><span style="color: #990000;">phpinfo</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<p>et aller voir dedans, normalement vous devriez voir l'extension activée.</p>
<p><img src="http://naeh.net/wp-content/uploads/2011/07/memecache-300x171.gif" alt="phpinfo memecache" title="phpinfo memecache" width="300" height="171" class="aligncenter size-medium wp-image-203" /></p>
<p>pour l'utilisation, rien de bien méchant, la doc php (http://php.net/manual/fr/book.memcache.php) est très bien faite <img src='http://naeh.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>petit bonus :</strong><br />
pour vérifier que le service est bien lancé, faite :</p>

<div class="wp_codebox"><table><tr id="p19840"><td class="code" id="p198code40"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">netstat</span> <span style="color: #660033;">-latupen</span> <span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">grep</span> memcached
résultat :
tcp        <span style="color: #000000;">0</span>      <span style="color: #000000;">0</span> 127.0.0.1:<span style="color: #000000;">11211</span>         0.0.0.0:<span style="color: #000000; font-weight: bold;">*</span>               LISTEN      <span style="color: #000000;">0</span>          <span style="color: #000000;">157533</span>      <span style="color: #000000;">5952</span><span style="color: #000000; font-weight: bold;">/</span>memcached</pre></td></tr></table></div>

<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fnaeh.net%2Finstaller-memcached-sous-debian-lenny%2F&amp;title=installer%20memcached%20sous%20debian%20lenny" id="wpa2a_8"><img src="http://naeh.net/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><img src="http://feeds.feedburner.com/~r/Naeh/~4/OwwfvrQfCq8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://naeh.net/installer-memcached-sous-debian-lenny/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://naeh.net/installer-memcached-sous-debian-lenny/</feedburner:origLink></item>
		<item>
		<title>Lancement de www.snippets.fr</title>
		<link>http://feedproxy.google.com/~r/Naeh/~3/uQDN4x6NemI/</link>
		<comments>http://naeh.net/lancement-de-www-snippets-fr/#comments</comments>
		<pubDate>Mon, 24 Jan 2011 21:15:18 +0000</pubDate>
		<dc:creator>Naeh</dc:creator>
				<category><![CDATA[Divers]]></category>
		<category><![CDATA[Programmation]]></category>

		<guid isPermaLink="false">http://naeh.net/?p=191</guid>
		<description><![CDATA[j'ai le plaisir de vous annoncer le lancement d'un nouveau site, http://www.snippets.fr. comme son nom l'indique, ce site est là pour regrouper des snippets dans différents langages (php seulement pour l'instant) et sur des tehcno que j'utilise au quotidien (Drupal, Magento, WordPress, etc.) dans le boulot mais aussi pour mes projets perso. si vous avez [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://naeh.net/wp-content/uploads/2011/01/Capture.jpg"><img src="http://naeh.net/wp-content/uploads/2011/01/Capture-300x119.jpg" alt="" title="snippets.fr" width="300" height="119" class="aligncenter size-medium wp-image-192" /></a></p>
<p>j'ai le plaisir de vous annoncer le lancement d'un nouveau site, <a href="http://www.snippets.fr">http://www.snippets.fr</a>.</p>
<p>comme son nom l'indique, ce site est là pour regrouper des snippets dans différents langages (php seulement pour l'instant) et sur des tehcno que j'utilise au quotidien (Drupal, Magento, WordPress, etc.) dans le boulot mais aussi pour mes projets perso.</p>
<p>si vous avez des snippets qui trainent, vous savez où les contribuer maintenant <img src='http://naeh.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Bon surf.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fnaeh.net%2Flancement-de-www-snippets-fr%2F&amp;title=Lancement%20de%20www.snippets.fr" id="wpa2a_10"><img src="http://naeh.net/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><img src="http://feeds.feedburner.com/~r/Naeh/~4/uQDN4x6NemI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://naeh.net/lancement-de-www-snippets-fr/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://naeh.net/lancement-de-www-snippets-fr/</feedburner:origLink></item>
		<item>
		<title>Aide et Astuces Windows 7</title>
		<link>http://feedproxy.google.com/~r/Naeh/~3/rHRAEmiK5cU/</link>
		<comments>http://naeh.net/aide-et-astuces-windows-7/#comments</comments>
		<pubDate>Sun, 14 Nov 2010 16:56:15 +0000</pubDate>
		<dc:creator>Naeh</dc:creator>
				<category><![CDATA[Divers]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Windows - OS]]></category>

		<guid isPermaLink="false">http://naeh.net/?p=185</guid>
		<description><![CDATA[Voici un court billet pour afin de partager un article fort intéressant (à mon goût :p) montrant quelques astuces qui pourraient se révéler très utiles pour l'utilisation de vos windows 7 de tous les jours, surtout maintenant que cet OS commence à se généraliser... Voici le lien : Aide et Astuces Windows 7 Bonne lecture.]]></description>
			<content:encoded><![CDATA[<p>Voici un court billet pour afin de partager un article fort intéressant (à mon goût :p) montrant quelques astuces qui pourraient se révéler très utiles pour l'utilisation de vos windows 7 de tous les jours, surtout maintenant que cet OS commence à se généraliser...</p>
<p>Voici le lien : <a target="_blank" href="http://www.logiciel.net/aide-et-astuces-windows-7-6849.htm">Aide et Astuces Windows 7</a></p>
<p>Bonne lecture.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fnaeh.net%2Faide-et-astuces-windows-7%2F&amp;title=Aide%20et%20Astuces%20Windows%207" id="wpa2a_12"><img src="http://naeh.net/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><img src="http://feeds.feedburner.com/~r/Naeh/~4/rHRAEmiK5cU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://naeh.net/aide-et-astuces-windows-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://naeh.net/aide-et-astuces-windows-7/</feedburner:origLink></item>
		<item>
		<title>Utiliser des paquets de différentes versions de debian</title>
		<link>http://feedproxy.google.com/~r/Naeh/~3/yIdB5BGkw8I/</link>
		<comments>http://naeh.net/utiliser-des-paquets-de-differentes-versions-de-debian/#comments</comments>
		<pubDate>Mon, 06 Sep 2010 20:44:44 +0000</pubDate>
		<dc:creator>Naeh</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Linux - OS]]></category>
		<category><![CDATA[apt-get]]></category>
		<category><![CDATA[lenny]]></category>
		<category><![CDATA[paquet]]></category>
		<category><![CDATA[squeeze]]></category>

		<guid isPermaLink="false">http://naeh.net/?p=182</guid>
		<description><![CDATA[Aujourd'hui on va voir comment customiser les fichier source.list de debian afin de pouvoir installer des paquets de versions autres que la stable. avant de commencer, il faut savoir que la version actuelle de debian (donc la version stable) est : lenny la version qui nous intéresse est la testing ou bien squeeze (on pourrait [...]]]></description>
			<content:encoded><![CDATA[<p>Aujourd'hui on va voir comment customiser les fichier source.list de debian afin de pouvoir installer des paquets de versions autres que la stable.</p>
<p>avant de commencer, il faut savoir que la version actuelle de debian (donc la version stable) est : <strong>lenny</strong></p>
<p>la version qui nous intéresse est la testing ou bien <strong>squeeze</strong> (on pourrait s'intéresser à la sid (non stable) mais c'est à éviter)</p>
<p>pour plus d'infos sur ces versions : <a href="http://wiki.debian.org/DebianReleases">http://wiki.debian.org/DebianReleases</a></p>
<p>pour pouvoir installer des paquets de la squeeze sous lenny il faut éditer son fichier <em>/etc/apt/sources.list</em> en ajoutant :</p>

<div class="wp_codebox"><table><tr id="p18244"><td class="code" id="p182code44"><pre class="bach" style="font-family:monospace;">deb http://ftp.fr.debian.org/debian squeeze main
deb http://security.debian.org/ squeeze/updates main</pre></td></tr></table></div>

<p>en gros dupliquer les lignes existantes en remplaçant lenny (ou stable) par squeeze (on pourrait ajouter non-free après main en cas de besoin ; pour installer jdk par exemple...)</p>
<p>maintenant notre debian est configurée pour aller chercher ces paquets dans la branche squeeze, cool, mais c'est un peu la cata quand même <img src='http://naeh.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  en fait, on ne veut prendre dans squeeze que certains paquets, et par défaut on voudrait garder lenny quand même, pour cela il faut tout simplement le dire à la machine :</p>
<p>on édite le fichier <em>/etc/apt/apt.conf</em> (le créer si non existant)<br />
on met dedans la ligne suivante :</p>

<div class="wp_codebox"><table><tr id="p18245"><td class="code" id="p182code45"><pre class="bach" style="font-family:monospace;">APT::Default-Release &quot;stable&quot;;</pre></td></tr></table></div>

<p>et maintenant un simple apt-get install va aller chercher les paquets au bon endroit (c'est à dire : lenny)</p>
<p>et si on veut installer un paquet de squeeze, on fait :</p>

<div class="wp_codebox"><table><tr id="p18246"><td class="code" id="p182code46"><pre class="bach" style="font-family:monospace;">apt-get install --target-release squeeze MON-SUPPER-PAQUET-DE-SQUEEZE</pre></td></tr></table></div>

<p>et le tour est joué <img src='http://naeh.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>à l'heure actuelle lenny est la version stable, le jour où la stable change, il suffira d'adapter un peu tout ça.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fnaeh.net%2Futiliser-des-paquets-de-differentes-versions-de-debian%2F&amp;title=Utiliser%20des%20paquets%20de%20diff%C3%A9rentes%20versions%20de%20debian" id="wpa2a_14"><img src="http://naeh.net/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><img src="http://feeds.feedburner.com/~r/Naeh/~4/yIdB5BGkw8I" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://naeh.net/utiliser-des-paquets-de-differentes-versions-de-debian/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://naeh.net/utiliser-des-paquets-de-differentes-versions-de-debian/</feedburner:origLink></item>
		<item>
		<title>Iptables – supprimer une règle spécifique</title>
		<link>http://feedproxy.google.com/~r/Naeh/~3/MR_rWham6TY/</link>
		<comments>http://naeh.net/iptables-supprimer-une-regle-specifique/#comments</comments>
		<pubDate>Fri, 27 Aug 2010 14:16:34 +0000</pubDate>
		<dc:creator>Naeh</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Linux - Logiciels]]></category>
		<category><![CDATA[Linux - OS]]></category>
		<category><![CDATA[fail2ban]]></category>
		<category><![CDATA[iptables]]></category>

		<guid isPermaLink="false">http://naeh.net/?p=179</guid>
		<description><![CDATA[Si comme moi, vous utilisez fail2ban ce qui est une très bonne chose, et que comme moi vous avez oublié de lui dire d'ignorer votre IP ce qui est une mauvaise chose et que par malheur vous vous plantez X fois (chez moi au bout du 2eme fail en 2 heures ==> ban pendant 10 [...]]]></description>
			<content:encoded><![CDATA[<p>Si comme moi, vous utilisez fail2ban ce qui est une très bonne chose, et que comme moi vous avez oublié de lui dire d'ignorer votre IP ce qui est une mauvaise chose et que par malheur vous vous plantez X fois (chez moi au bout du 2eme fail en 2 heures ==> ban pendant 10 jours !)</p>
<p>pour commencer il faut trouver une autre porte d'entrée au serveur (une autre adresse IP)</p>
<p>en suite le but est de supprimer la règle concernant votre IP sans devoir toucher aux autres règles voici comment faire :</p>

<div class="wp_codebox"><table><tr id="p17950"><td class="code" id="p179code50"><pre class="bash" style="font-family:monospace;">iptables <span style="color: #660033;">-L</span> <span style="color: #660033;">--line-numbers</span></pre></td></tr></table></div>

<p>ce qui donne (entre autre) :</p>

<div class="wp_codebox"><table><tr id="p17951"><td class="code" id="p179code51"><pre class="bash" style="font-family:monospace;">Chain fail2ban-ssh <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span> references<span style="color: #7a0874; font-weight: bold;">&#41;</span>
num  target     prot opt <span style="color: #7a0874; font-weight: bold;">source</span>               destination
<span style="color: #000000;">1</span>    DROP       all  <span style="color: #660033;">--</span>  kol-static-<span style="color: #000000;">36</span>-<span style="color: #000000;">240</span>-<span style="color: #000000;">16</span>-<span style="color: #000000;">61</span>.direct.net.in  anywhere
<span style="color: #000000;">2</span>    DROP       all  <span style="color: #660033;">--</span>  unknown-host.yaltanet.com.ua  anywhere
<span style="color: #000000;">3</span>    RETURN     all  <span style="color: #660033;">--</span>  anywhere             anywhere</pre></td></tr></table></div>

<p>là on vois qu'il y a 2 ip bannies, il faut repérer le numéro de ligne de cette qu'on veut supprimer (ce qui revient à autoriser l'ip a se connecter au serveur)</p>

<div class="wp_codebox"><table><tr id="p17952"><td class="code" id="p179code52"><pre class="bash" style="font-family:monospace;">iptables <span style="color: #660033;">-D</span> fail2ban-ssh X</pre></td></tr></table></div>

<p>fail2ban-ssh : le nom de la chain créée par fail2ban pour le ssh<br />
X : le #numéro de ligne qui nous intéresse</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fnaeh.net%2Fiptables-supprimer-une-regle-specifique%2F&amp;title=Iptables%20%26%238211%3B%20supprimer%20une%20r%C3%A8gle%20sp%C3%A9cifique" id="wpa2a_16"><img src="http://naeh.net/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><img src="http://feeds.feedburner.com/~r/Naeh/~4/MR_rWham6TY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://naeh.net/iptables-supprimer-une-regle-specifique/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://naeh.net/iptables-supprimer-une-regle-specifique/</feedburner:origLink></item>
		<item>
		<title>Subversion 1.6 sur Debian lenny</title>
		<link>http://feedproxy.google.com/~r/Naeh/~3/WfCEgQDxfpQ/</link>
		<comments>http://naeh.net/subversion-1-6-sur-debian-lenny/#comments</comments>
		<pubDate>Wed, 30 Jun 2010 18:56:54 +0000</pubDate>
		<dc:creator>Naeh</dc:creator>
				<category><![CDATA[Linux - Logiciels]]></category>
		<category><![CDATA[svn subversion debian backports]]></category>

		<guid isPermaLink="false">http://naeh.net/?p=169</guid>
		<description><![CDATA[alors là c'est le billet mémo par excellence étant utilisateur occasionnel de tortoiseSVN à jour, impossible pour moi d'utiliser svn en ligne de commande (beaucoup plus rapide que tortoise) sur ma debian, d'où l'idée de d'installer svn 1.6 qui n'est pas disponible dans les paquets debian. la procédure consiste a utiliser les backports, elle est [...]]]></description>
			<content:encoded><![CDATA[<p>alors là c'est le billet mémo par excellence <img src='http://naeh.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>étant utilisateur occasionnel de tortoiseSVN à jour, impossible pour moi d'utiliser svn en ligne de commande (beaucoup plus rapide que tortoise) sur ma debian, d'où l'idée de d'installer svn 1.6 qui n'est pas disponible dans les paquets debian.</p>
<p>la procédure consiste a utiliser les backports, elle est très simple, encore faut-il la connaitre (ou la trouver facilement)</p>
<p>pour commencer il faut savoir que svn 1.5 doit être déjà installé sur la machine, si ce n'est pas le cas, faire :</p>

<div class="wp_codebox"><table><tr id="p16957"><td class="code" id="p169code57"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> subversion subversion-tools apache2 libapache2-svn</pre></td></tr></table></div>

<p>1. configuration du sources.list<br />
il faut ajouter cette ligne à la fin du fichier <em>/etc/apt/sources.list</em></p>

<div class="wp_codebox"><table><tr id="p16958"><td class="code" id="p169code58"><pre class="sh" style="font-family:monospace;">deb http://www.backports.org/debian lenny-backports main contrib non-free</pre></td></tr></table></div>

<p>2. mettre à jour la base de paquets :</p>

<div class="wp_codebox"><table><tr id="p16959"><td class="code" id="p169code59"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> update</pre></td></tr></table></div>

<p>3. on instalel svn en spécifiant la source (backports) :</p>

<div class="wp_codebox"><table><tr id="p16960"><td class="code" id="p169code60"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #660033;">-t</span> lenny-backports <span style="color: #c20cb9; font-weight: bold;">install</span> subversion subversion-tools libapache2-svn</pre></td></tr></table></div>

<p>et maintenant on peut utiliser svn en ligne de commande avec des référentiels "commités" avec des version récentes de subversion (comme tortoise)</p>
<p>Source du tuto : <a href="http://swherdman.com/2009/05/subversion-16-on-debian-lenny/">http://swherdman.com/2009/05/subversion-16-on-debian-lenny/</a></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fnaeh.net%2Fsubversion-1-6-sur-debian-lenny%2F&amp;title=Subversion%201.6%20sur%20Debian%20lenny" id="wpa2a_18"><img src="http://naeh.net/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><img src="http://feeds.feedburner.com/~r/Naeh/~4/WfCEgQDxfpQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://naeh.net/subversion-1-6-sur-debian-lenny/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://naeh.net/subversion-1-6-sur-debian-lenny/</feedburner:origLink></item>
		<item>
		<title>Configuration d'Exim avec nom de domaine géré par gandi</title>
		<link>http://feedproxy.google.com/~r/Naeh/~3/qagZTiarW7c/</link>
		<comments>http://naeh.net/configuration-dexim-avec-nom-de-domaine-gere-par-gandi/#comments</comments>
		<pubDate>Sat, 27 Mar 2010 12:26:40 +0000</pubDate>
		<dc:creator>Naeh</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Linux - Logiciels]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[exim]]></category>
		<category><![CDATA[gandi]]></category>
		<category><![CDATA[postfix]]></category>

		<guid isPermaLink="false">http://naeh.net/?p=151</guid>
		<description><![CDATA[Bonjour, aujourd'hui nous allons voir comment, facilement, exploiter une fonctionnalité offerte par Gandi (ou bien comprise dans le prix de nom de domaine, ça dépend comment on voit les choses). beaucoup d'entre nous n'ont pas le temps (et souvent pas l'envie de non plus) de se prendre la tête avec un vrai MTA genre postfix [...]]]></description>
			<content:encoded><![CDATA[<p>Bonjour,</p>
<p>aujourd'hui nous allons voir comment, facilement, exploiter une fonctionnalité offerte par Gandi (ou bien comprise dans le prix de nom de domaine, ça dépend comment on voit les choses).</p>
<p>beaucoup d'entre nous n'ont pas le temps (et souvent pas l'envie de non plus) de se prendre la tête avec un vrai MTA genre postfix ou exim et le configurer en s'assurant de bien renseigner les enregistrement MX chez le registrar, d'installer les bons outils pour le POP (ou IMAP) etc. etc.</p>
<p>il faut savoir qu'avec un nom de domaine de chez Gandi, on a droit a quelques comptes emails (5 par domaine de mémoire) et une infinité d'alias sur ces comptes.</p>
<p>ce qu'on va voir ici, c'est comment configurer une machine (serveur dédié) pour assurer le minimum syndical en s'appuyant sur le service proposé par gandi.</p>
<p>dans notre exemple il s'agira d'un Exim4 (c'est le seul avec lequel j'ai testé pour l'instant, et ça marche tellement bien que je n'ai pas envie de changer <img src='http://naeh.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />   )</p>
<p>on va supposer un compte admin@mon-domaine.com</p>
<p>tout d'abord il faut éditer le fichier : <strong>/etc/exim4/passwd.client</strong> en ajoutant tout à la fin :</p>

<div class="wp_codebox"><table><tr id="p15165"><td class="code" id="p151code65"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">*</span>:admin<span style="color: #000000; font-weight: bold;">@</span>mon-domaine.com:MOT-DE-PASSE-DU-COMPTE</pre></td></tr></table></div>

<p>en suite, on va éditer le fichier <strong>/etc/exim4/update-exim4.conf.conf</strong> pour avoir quelque chose comme :</p>

<div class="wp_codebox"><table><tr id="p15166"><td class="code" id="p151code66"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">dc_eximconfig_configtype</span>=<span style="color: #ff0000;">'satellite'</span>
<span style="color: #007800;">dc_other_hostnames</span>=<span style="color: #ff0000;">''</span>
<span style="color: #007800;">dc_local_interfaces</span>=<span style="color: #ff0000;">'127.0.0.1'</span>
<span style="color: #007800;">dc_readhost</span>=<span style="color: #ff0000;">'mon-domaine.com'</span>
<span style="color: #007800;">dc_relay_domains</span>=<span style="color: #ff0000;">''</span>
<span style="color: #007800;">dc_minimaldns</span>=<span style="color: #ff0000;">'false'</span>
<span style="color: #007800;">dc_relay_nets</span>=<span style="color: #ff0000;">''</span>
<span style="color: #007800;">dc_smarthost</span>=<span style="color: #ff0000;">'mail.gandi.net:587'</span>
<span style="color: #007800;">CFILEMODE</span>=<span style="color: #ff0000;">'644'</span>
<span style="color: #007800;">dc_use_split_config</span>=<span style="color: #ff0000;">'false'</span>
<span style="color: #007800;">dc_hide_mailname</span>=<span style="color: #ff0000;">'true'</span>
<span style="color: #007800;">dc_mailname_in_oh</span>=<span style="color: #ff0000;">'true'</span>
<span style="color: #007800;">dc_localdelivery</span>=<span style="color: #ff0000;">'mail_spool'</span></pre></td></tr></table></div>

<p>un petit</p>

<div class="wp_codebox"><table><tr id="p15167"><td class="code" id="p151code67"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>exim4 reload</pre></td></tr></table></div>

<p>et le tour est joué <img src='http://naeh.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>votre serveur envoie maintenant ces mails en utilisant le compte gandi, plus de soucis de conf complexe, maj à risque etc a se faire...</p>
<p>pour tester :</p>

<div class="wp_codebox"><table><tr id="p15168"><td class="code" id="p151code68"><pre class="bash" style="font-family:monospace;">test-machine:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>exim4<span style="color: #666666; font-style: italic;"># mail user@omain.tld</span>
Subject: <span style="color: #7a0874; font-weight: bold;">test</span>
ceci est un message de <span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000; font-weight: bold;">!</span>
.
Cc:</pre></td></tr></table></div>

<p>PS. procédure trouvé il y a un moment sur les forums gandi, mais je n'arrive jamais a la retrouver je la mets ici, au cas où.<br />
PS2. comme d'habitude, notre distribution ici est une Debian <img src='http://naeh.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fnaeh.net%2Fconfiguration-dexim-avec-nom-de-domaine-gere-par-gandi%2F&amp;title=Configuration%20d%26%23039%3BExim%20avec%20nom%20de%20domaine%20g%C3%A9r%C3%A9%20par%20gandi" id="wpa2a_20"><img src="http://naeh.net/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><img src="http://feeds.feedburner.com/~r/Naeh/~4/qagZTiarW7c" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://naeh.net/configuration-dexim-avec-nom-de-domaine-gere-par-gandi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://naeh.net/configuration-dexim-avec-nom-de-domaine-gere-par-gandi/</feedburner:origLink></item>
	</channel>
</rss>

