{"id":322,"date":"2019-07-02T14:28:05","date_gmt":"2019-07-02T14:28:05","guid":{"rendered":"https:\/\/silviamarin.ro\/?p=55"},"modified":"2019-07-02T14:28:05","modified_gmt":"2019-07-02T14:28:05","slug":"securizarea-serverului-apache-cu-lets-encrypt-2","status":"publish","type":"post","link":"https:\/\/marinelvis.xyz\/index.php\/2019\/07\/02\/securizarea-serverului-apache-cu-lets-encrypt-2\/","title":{"rendered":"SECURIZAREA SERVERULUI APACHE CU LET&#8217;S ENCRYPT"},"content":{"rendered":"<p>Se actualizeaza sursele:<\/p>\n<pre>apt update<\/pre>\n<p>Se instaleaza Certbot:<\/p>\n<pre>apt install -y python3-certbot-apache\ncertbot --apache<\/pre>\n<p>Certbot genereaza certificatele localizate in <em>\/etc\/letsencrypt\/live\/<span style=\"color: #ff0000;\">marinelvis.xyz\/<\/span><\/em><\/p>\n<p><em><strong>a. HTTP Challenge validation<\/strong><\/em><br \/>\nSe opreste serverul Apache apoi se genereaza certificatul:<\/p>\n<pre>systemctl stop apache2.service\ncertbot certonly --standalone -d <em><span style=\"color: #ff0000;\">marinelvis<\/span><\/em><span style=\"color: #ff0000;\">.ro<\/span> -d <em><span style=\"color: #ff0000;\">marinelvis<\/span><\/em><span style=\"color: #ff0000;\">.ro<\/span><\/pre>\n<p><em><strong>b. Obtinerea certificatelor Let&#8217;s Encrypt cu wildcard<\/strong><\/em><br \/>\nSe opreste serverul Apache\u00a0apoi se genereaza certificatele:<\/p>\n<pre>systemctl stop apache2.service\ncertbot certonly --server https:\/\/acme-v02.api.letsencrypt.org\/directory --manual --preferred-challenges dns -d '<span style=\"color: #ff0000;\">marinelvis.xyz\/<\/span>,*.<span style=\"color: #ff0000;\">marinelvis.xyz\/<\/span>'<\/pre>\n<p>Certbot furnizeaza instructiuni pentru inregistrarea TXT pentru domeniu:<\/p>\n<blockquote><p><em>Please deploy a DNS TXT record under the name <\/em><em>_acme-challenge.<span style=\"color: #ff0000;\">marinelvis<\/span><span style=\"color: #ff0000;\">.ro<\/span><\/em><em>\u00a0with the following value:<\/em><br \/>\n<em>667drNmQL3vX6bu8Y<\/em><em>y0wKNBlCny8yrjF1lSaUndc<\/em><br \/>\n<em>Once this is deployed,<\/em><em>Press ENTER to continue<\/em><\/p><\/blockquote>\n<p>Se genereaza inregistrarea TXT cu datele furnizate de Certbot in DNS Zone Management a hosting-ului apoi Enter si se continua derularea scriptului.<br \/>\nPentru <a href=\"https:\/\/freedns.afraid.org\/subdomain\/\">freedns.afraid.org<\/a> se introduce\u00a0 <em>_acme-challenge\u00a0<\/em>la &#8222;Subdomain&#8221; iar inregistrarea TXT la &#8222;Destination&#8221; pusa intre ghilimele<br \/>\n<em><strong>c. DNS challenge validation<\/strong><\/em><br \/>\nSe opreste serverul Apache apoi se genereaza certificatele:<\/p>\n<pre>certbot -d <span style=\"color: #ff0000;\"><em>marinelvis<\/em>.ro<\/span>, -d <span style=\"color: #ff0000;\">www.<em>marinelvis<\/em>.ro<\/span> --manual --preferred-challenges dns certonly<\/pre>\n<p><span style=\"line-height: 1.5;\">Certbot furnizeaza instructiuni pentru inregistrarea TXT pentru domeniu:<\/span><\/p>\n<blockquote><p><em>Please deploy a DNS TXT record under the name<\/em><br \/>\n<em>_acme-challenge.<span style=\"color: #ff0000;\">marinelvis<\/span><span style=\"color: #ff0000;\">.ro<\/span><\/em><em>\u00a0with the following value:<\/em><\/p>\n<p><em>667drNmQL3vX6bu8Y<\/em><em>Zlgy0wKNBlCny8yrjF1lSaUndc<\/em><em>Once this is deployed,<\/em><br \/>\n<em>Press ENTER to continue<\/em><\/p><\/blockquote>\n<p>Se genereaza inregistrarea TXT cu datele furnizate de Certbot in DNS Zone a hosting-ului apoi Enter si se continua derularea scriptului.<\/p>\n<p>Se deschide apoi fisierul <em>\/etc\/apache2\/sites-available\/<span style=\"color: #ff0000;\">marinelvis<\/span><span style=\"color: #ff0000;\">.ro<\/span>.conf<\/em>:<\/p>\n<pre>nano \/etc\/apache2\/sites-available\/<span style=\"color: #ff0000;\">marinelvis<\/span><span style=\"color: #ff0000;\">.ro<\/span>.conf<\/pre>\n<p>Se inlocuieste continutul cu urmatorul:<\/p>\n<blockquote><p><em>&lt;VirtualHost *:80&gt;<\/em><br \/>\n<em>ServerName <span style=\"color: #ff0000;\">marinelvis<\/span><span style=\"color: #ff0000;\">.ro<\/span><\/em><br \/>\n<em>ServerAlias www.<span style=\"color: #ff0000;\">marinelvis<\/span><span style=\"color: #ff0000;\">.ro<\/span><\/em><br \/>\n<em>Redirect permanent \/ https:\/\/<span style=\"color: #ff0000;\">marinelvis<\/span><span style=\"color: #ff0000;\">.ro<\/span><\/em><br \/>\n<em>DocumentRoot \/var\/www\/<span style=\"color: #ff0000;\">marinelvis<\/span><span style=\"color: #ff0000;\">.ro<\/span>\/html<\/em><br \/>\n<em>&lt;\/VirtualHost&gt;<\/em><br \/>\n<em>&lt;VirtualHost *:443&gt;<\/em><br \/>\n<em>ServerAdmin <span style=\"color: #ff0000;\">webmaster@localhost<\/span><\/em><br \/>\n<em>ServerName <span style=\"color: #ff0000;\">marinelvis<\/span><span style=\"color: #ff0000;\">.ro<\/span><\/em><br \/>\n<em>DocumentRoot \/var\/www\/<span style=\"color: #ff0000;\">marinelvis<\/span><span style=\"color: #ff0000;\">.ro<\/span>\/html<\/em><br \/>\n<em>SSLEngine on <\/em><br \/>\n<em>SSLCertificateFile \/etc\/letsencrypt\/live\/<span style=\"color: #ff0000;\">marinelvis<\/span><span style=\"color: #ff0000;\">.ro<\/span>\/fullchain.pem <\/em><br \/>\n<em>SSLCertificateKeyFile \/etc\/letsencrypt\/live\/<span style=\"color: #ff0000;\">marinelvis<\/span><span style=\"color: #ff0000;\">.ro<\/span>\/privkey.pem <\/em><br \/>\n<em>ErrorLog ${APACHE_LOG_DIR}\/error.log<\/em><br \/>\n<em>CustomLog ${APACHE_LOG_DIR}\/access.log combined<\/em><br \/>\n<em>&lt;\/VirtualHost&gt;<\/em><\/p><\/blockquote>\n<p>Se activeaza modulul SSL al serverului Apache si se reporneste<\/p>\n<pre>a2enmod ssl \nsystemctl restart apache2<\/pre>\n<p>Se activeaza suportul pentru &#8222;perfect forward secrecy&#8221; in modulul ssl:<\/p>\n<pre>nano\u00a0\/etc\/apache2\/mods-available\/ssl.conf<\/pre>\n<p>Se activeaza \u00a0<em>&#8222;SSLHonorCipherOrder on&#8221;<\/em> si se inlocuieste <em>&#8222;SSLCipherSuite HIGH:!aNULL&#8221;<\/em> cu<br \/>\n<em style=\"line-height: 1.5;\">SSLCipherSuite ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA:DHE-RSA-CAMELLIA128-SHA:AES128-SHA:RC4-SHA:HIGH:!aNULL:!MD5:!ADH<br \/>\n<\/em><br \/>\nSe salveaza fisierul si se reporneste serverul Apache<\/p>\n<pre>systemctl restart apache2.service<\/pre>\n<p><em><strong>Mai multe site-uri pe acelasi server Apache<\/strong><\/em><br \/>\n\u00cen <em>\/etc\/apache2\/sites-available\/<\/em> se creeaza fisierele de configurare pentru fiecare domeniu\/subdomeniu suplimentar:<\/p>\n<pre>mkdir -p \/var\/www\/<em><span style=\"color: #ff0000;\">marinelvis<\/span><\/em><span style=\"color: #ff0000;\">.ro<\/span>\/<span style=\"color: #ff0000;\">subdomeniu<\/span> \ncp \/var\/www\/html\/index.html \/var\/www\/<span style=\"color: #ff0000;\">marinelvis<\/span><span style=\"color: #ff0000;\">.ro<\/span>\/<span style=\"color: #ff0000;\">subdomeniu<\/span> \nchown -R www-data:www-data \/var\/www\nnano \/etc\/apache2\/sites-available\/<span style=\"color: #ff0000;\">subdomeniu.marinelvis.ro<\/span>.conf<\/pre>\n<p>Se introduc informatiile pentru fiecare site\/subdomeniu \u00een parte:<\/p>\n<blockquote><p><em>&lt;VirtualHost *:80&gt;<\/em><br \/>\n<em>ServerName <span style=\"color: #ff0000;\">subdomeniu.marinelvis.ro<\/span><\/em><br \/>\n<em>ServerAlias www.<span style=\"color: #ff0000;\">subdomeniu.marinelvis.ro<\/span><\/em><br \/>\n<em>Redirect permanent \/ https:\/\/<span style=\"color: #ff0000;\">subdomeniu.marinelvis.ro<\/span><\/em><br \/>\n<em>DocumentRoot \/var\/www\/<span style=\"color: #ff0000;\">marinelvis<\/span><span style=\"color: #ff0000;\">.ro<\/span>\/<span style=\"color: #ff0000;\">subdomeniu<\/span><\/em><br \/>\n<em>&lt;\/VirtualHost&gt;<\/em><br \/>\n<em>&lt;VirtualHost *:443&gt;<\/em><br \/>\n<em>ServerAdmin <span style=\"color: #ff0000;\">webmaster@localhost<\/span><\/em><br \/>\n<em>ServerName <span style=\"color: #ff0000;\">subdomeniu.marinelvis.ro<\/span><\/em><br \/>\n<em>DocumentRoot \/var\/www\/<span style=\"color: #ff0000;\">marinelvis<\/span><span style=\"color: #ff0000;\">.ro<\/span>\/<span style=\"color: #ff0000;\">subdomeniu <\/span><\/em><br \/>\n<em>SSLEngine on <\/em><br \/>\n<em>SSLCertificateFile \/etc\/letsencrypt\/live\/<span style=\"color: #ff0000;\">marinelvis<\/span><span style=\"color: #ff0000;\">.ro<\/span>\/fullchain.pem <\/em><br \/>\n<em>SSLCertificateKeyFile \/etc\/letsencrypt\/live\/<span style=\"color: #ff0000;\">marinelvis<\/span><span style=\"color: #ff0000;\">.ro<\/span>\/privkey.pem <\/em><br \/>\n<em>ErrorLog ${APACHE_LOG_DIR}\/error.log<\/em><br \/>\n<em>CustomLog ${APACHE_LOG_DIR}\/access.log combined<\/em><br \/>\n<em>&lt;\/VirtualHost&gt;<\/em><\/p><\/blockquote>\n<p>Se salveaza fisierele, se activeaza fiecare site \u00een parte \u015fi se reporneste Apache:<\/p>\n<pre>a2ensite <span style=\"color: #ff0000;\">subdomeniu.marinelvis.ro<\/span>.conf\nsystemctl restart apache2.service<\/pre>\n<p>Certificatele Let&#8217;s Encrypt se reinnoiesc la fiecare 90 de zile. Pentru reinnoirea cu subdomenii se editeaza fisierul de configurare <em><span style=\"color: #ff0000;\">marinelvis<\/span><\/em><em><span style=\"color: #ff0000;\">.ro<\/span><\/em>.conf din <em>\/etc\/letsencrypt\/renewal<\/em>. La\u00a0<em>[renewalparams]<\/em> se introduce randul:<\/p>\n<blockquote><p><em>allow_subset_of_names = True<\/em><\/p><\/blockquote>\n<p>Revocarea certificatelor se face cu comanda:<\/p>\n<pre>certbot revoke --cert-path \/etc\/letsencrypt\/archive\/<span style=\"color: #ff0000;\">marinelvis<\/span><span style=\"color: #ff0000;\">.ro<\/span>\/cert1.pem<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Se actualizeaza sursele: apt update Se instaleaza Certbot: apt install -y python3-certbot-apache certbot &#8211;apache Certbot genereaza certificatele localizate in \/etc\/letsencrypt\/live\/marinelvis.xyz\/ a. HTTP Challenge validation Se opreste serverul Apache apoi se genereaza certificatul: systemctl stop apache2.service certbot certonly &#8211;standalone -d marinelvis.ro -d marinelvis.ro b. Obtinerea certificatelor Let&#8217;s Encrypt cu wildcard Se opreste serverul Apache\u00a0apoi se genereaza [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-322","post","type-post","status-publish","format-standard","hentry","category-fara-categorie"],"_links":{"self":[{"href":"https:\/\/marinelvis.xyz\/index.php\/wp-json\/wp\/v2\/posts\/322","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/marinelvis.xyz\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/marinelvis.xyz\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/marinelvis.xyz\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/marinelvis.xyz\/index.php\/wp-json\/wp\/v2\/comments?post=322"}],"version-history":[{"count":0,"href":"https:\/\/marinelvis.xyz\/index.php\/wp-json\/wp\/v2\/posts\/322\/revisions"}],"wp:attachment":[{"href":"https:\/\/marinelvis.xyz\/index.php\/wp-json\/wp\/v2\/media?parent=322"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/marinelvis.xyz\/index.php\/wp-json\/wp\/v2\/categories?post=322"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/marinelvis.xyz\/index.php\/wp-json\/wp\/v2\/tags?post=322"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}