{"id":2868,"date":"2018-02-13T16:47:40","date_gmt":"2018-02-13T13:47:40","guid":{"rendered":"https:\/\/www.howtoforge.com\/tutorial\/securing-ispconfig-3-with-a-free-lets-encrypt-ssl-certificate\/"},"modified":"2018-02-13T16:47:40","modified_gmt":"2018-02-13T13:47:40","slug":"securing-ispconfig-3-1-with-a-free-lets-encrypt-ssl-certificate","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/securing-ispconfig-3-1-with-a-free-lets-encrypt-ssl-certificate\/","title":{"rendered":"Securing ISPConfig 3.1 With a Free Let&#8217;s Encrypt SSL Certificate"},"content":{"rendered":"<div><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/02\/securing-ispconfig-3-1-with-a-free-lets-encrypt-ssl-certificate.gif\" class=\"ff-og-image-inserted\" alt=\"\" title=\"\"><\/div>\n<p>Author:\u00a0<a href=\"https:\/\/www.howtoforge.com\/community\/members\/ahrasis.76386\/\" target=\"_blank\" rel=\"noopener\">ahrasis<\/a><\/p>\n<p>This tutorial shows how to create and configure a free Let&#8217;s encrypt SSL certificate for the ISPconfig interface (port 8080), the email system (Postfix and Dovecot\/Courier), the FTP server (pure-ftpd) and Monit. The commands\u00a0in this tutorial have been tested on Ubuntu 16.04, they should work for Debian as well. Certain modifications may be necessary to make it work on CentOS.<\/p>\n<p>Help on this guide is available in this <a href=\"https:\/\/www.howtoforge.com\/community\/threads\/securing-ispconfig-3-control-panel-port-8080-with-lets-encrypt-free-ssl.75554\/\" target=\"_blank\" rel=\"noopener\">forum thread<\/a>.<\/p>\n<h2 id=\"creating-a-website-using-ispconfig-server-hostname-fqdn\">Creating A Website Using ISPConfig Server Hostname FQDN<\/h2>\n<p>Create a site for your server in ISPConfig panel via <em><strong>Sites &gt; Website &gt; Add new website<\/strong><\/em>. Remember! This is your server website and as such it must contain your server fully qualified domain name (FQDN). I will refer to it as `hostname -f` in this guide.<\/p>\n<p class=\"command\"><span>hostname -f<\/span><\/p>\n<p>Hopefully, it will work without any changes to your server as well.<\/p>\n<h2 id=\"accessing-ispconfig-website-online\">Accessing ISPConfig Website Online<\/h2>\n<p>Check if your server site is ready and accessible online as Let&#8217;s Encrypt needs to verify your website is accessible before issuing SSL key, certificate and chain file for your server site. You also have to create its DNS zone and allow it to properly propagate as Let&#8217;s Encrypt needs to verify it too.<\/p>\n<h2 id=\"enabling-ssl-for-ispconfig-control-panel-port-\">Enabling SSL For ISPConfig 3 Control Panel (Port 8080)<\/h2>\n<p>If you haven&#8217;t enabled SSL during ISPConfig setup i.e. for its control panel at port 8080, enable it by typing ispconfig_update.sh in the terminal and select yes for SSL. We don&#8217;t need this to be a proper key nor do we want to keep it but we want to work faster, thus we can simply enter for all of its fields. When you finished this, the self-signed SSL should already be enabled for your ISPConfig.<\/p>\n<h2 id=\"checking-ssl-for-ispconfig-control-panel-port-\">Checking SSL For ISPConfig 3 Control Panel (Port 8080)<\/h2>\n<p>Check your browser to confirm by opening ISPConfig control panel at port 8080. Note that you might get some warning at this stage since the created SSL files are self-signed but the browser will confirm that your ISPConfig has SSL enabled or otherwise.<\/p>\n<h2 id=\"securing-ispconfig-website-with-lets-encrypt-ssl\">Securing ISPConfig Website With Let&#8217;s Encrypt SSL<\/h2>\n<p>If the above is done, go back to <strong><em>ISPConfig panel &gt; Sites &gt; Website &gt; Website Name<\/em><\/strong>, then click <strong>SSL<\/strong> and <strong>Let&#8217;s Encrypt<\/strong> check buttons and save &#8211; to create Let&#8217;s Encrypt SSL files and enable them for your server site. If successful your server site shall now be using this Let&#8217;s Encrypt SSL files but not your ISPConfig 8080 page. If unsuccessful, you will not be able to proceed further, so do check its log file for a clue.<\/p>\n<h2 id=\"changing-ispconfig-control-panel-port-\">Changing ISPConfig 3 Control Panel (Port 8080)<\/h2>\n<p>If LE SSL is already working, then go to your server terminal, go root via sudo su and use the following command to backup and replace the created self-signed SSL files with Let&#8217;s Encrypt SSL files.<\/p>\n<p class=\"command\">cd \/usr\/local\/ispconfig\/interface\/ssl\/<br \/>mv ispserver.crt ispserver.crt-$(date +&#8221;%y%m%d%H%M%S&#8221;).bak<br \/>mv ispserver.key ispserver.key-$(date +&#8221;%y%m%d%H%M%S&#8221;).bak<br \/>mv ispserver.pem ispserver.pem-$(date +&#8221;%y%m%d%H%M%S&#8221;).bak<br \/>ln -s \/etc\/letsencrypt\/live\/$(hostname -f)\/fullchain.pem ispserver.crt<br \/>ln -s \/etc\/letsencrypt\/live\/$(hostname -f)\/privkey.pem ispserver.key<br \/>cat ispserver.{key,crt} &gt; ispserver.pem<br \/>chmod 600 ispserver.pem<\/p>\n<ul>\n<li>If you haven&#8217;t created ispserver.pem before, you may ignore the third line which is aimed at renaming the existing one, if any, as a backup.<\/li>\n<li>ote that we are using Let&#8217;s Encrypt live folder instead of archive folder.<\/li>\n<li>Also note the last line where ispserver.pem is created by combining files, thuswise, it will not be automatically renewed by Let&#8217;s Encrypt unlike other files which we merely symlinked them, thus, we will deal with this in the last part of this guide.<\/li>\n<li>Note also that you either type in `hostname -f` or server1.example.com as the result is the same because `hostname -f`is server1.example.com.<\/li>\n<\/ul>\n<h2 id=\"using-the-same-lets-encrypt-ssl-certs-for-other-major-services\">Using The Same Let&#8217;s Encrypt SSL Certs For Other Major Services<\/h2>\n<p>As additional tips, based on Securing Your ISPConfig 3 Installation you may want to use symlink to ispserver.key or .crt or .pem instead of directly pointing your postfix, dovecot, courier, pure-FTPd and monit to Let&#8217;s Encrypt SSL files. For dovecot, if it is already using postfix SSL files, it is safe for you to ignore it. In details you only need to do the followings:<\/p>\n<h3 id=\"a-for-postfix\">a. For Postfix<\/h3>\n<p class=\"command\">cd \/etc\/postfix\/<br \/>mv smtpd.cert smtpd.cert-$(date +&#8221;%y%m%d%H%M%S&#8221;).bak<br \/>mv smtpd.key smtpd.key-$(date +&#8221;%y%m%d%H%M%S&#8221;).bak<br \/>ln -s \/usr\/local\/ispconfig\/interface\/ssl\/ispserver.crt smtpd.cert<br \/>ln -s \/usr\/local\/ispconfig\/interface\/ssl\/ispserver.key smtpd.key<br \/>service postfix restart<br \/>service dovecot restart<\/p>\n<h3 id=\"b-for-dovecot-note-this-shouldnt-exist-together-with-courier\">b. For dovecot: (* Note this shouldn&#8217;t exist together with courier)<\/h3>\n<p>Check if this code exist by using nano \/etc\/dovecot\/dovecot.conf<\/p>\n<pre>[...]<br\/>ssl_cert = &lt;\/etc\/postfix\/smtpd.cert<br\/>ssl_key = &lt;\/etc\/postfix\/smtpd.key<br\/>[...]<\/pre>\n<p>Leave them as they are if they exist. Otherwise, fix them. In any event, run service dovecot restart is already covered above.<\/p>\n<h3 id=\"c-for-courier-note-this-shouldnt-exist-together-with-dovecot\">c. For courier: (* Note this shouldn&#8217;t exist together with dovecot)<\/h3>\n<p class=\"command\">cd \/etc\/courier\/<br \/>mv imapd.pem imapd.pem-$(date +&#8221;%y%m%d%H%M%S&#8221;).bak<br \/>mv pop3d.pem pop3d.pem-$(date +&#8221;%y%m%d%H%M%S&#8221;).bak<br \/>ln -s \/usr\/local\/ispconfig\/interface\/ssl\/ispserver.pem imapd.pem<br \/>ln -s \/usr\/local\/ispconfig\/interface\/ssl\/ispserver.pem pop3d.pem<br \/>service courier-imap-ssl stop<br \/>service courier-imap-ssl start<br \/>service courier-pop-ssl stop<br \/>service courier-pop-ssl start<\/p>\n<h3 id=\"d-for-pureftpd\">d. For pure-FTPd:<\/h3>\n<p>cd \/etc\/ssl\/private\/<br \/>mv pure-ftpd.pem pure-ftpd.pem-$(date +&#8221;%y%m%d%H%M%S&#8221;).bak<br \/>ln -s \/usr\/local\/ispconfig\/interface\/ssl\/ispserver.pem pure-ftpd.pem<br \/>chmod 600 pure-ftpd.pem<br \/>service pure-ftpd-mysql restart<\/p>\n<h3 id=\"e-for-monit-if-you-have-it-installed-in-your-server\">e. For monit: (If you have it installed in your server)<\/h3>\n<p class=\"command\">nano \/etc\/monit\/monitrc<\/p>\n<p>Add the above symlink to ispserver.pem we created for pure-ftpd in here as well:<\/p>\n<pre>[...]<br\/>set httpd port 2812 and<br\/>SSL ENABLE<br\/>PEMFILE \/etc\/ssl\/private\/pure-ftpd.pem<br\/>allow admin:'secretpassword'<br\/>[...]<\/pre>\n<p>And restart monit:<\/p>\n<p class=\"command\">service monit restart<\/p>\n<h2 id=\"create-auto-renewal-script-for-your-ispconfig-pem-file-ispserverpem\">Create Auto Renewal Script For Your ISPConfig Pem File (ispserver.pem)<\/h2>\n<p>In this last step, which I haven&#8217;t found in any guide so far, is the automatic update of ispserver.pem as earlier hinted. Currently, it have to be manually changed right after Let&#8217;s Encrypt automatically renewed your server SSL files. To avoid overlooking this, you may want to install incron as suggested in the respective <a href=\"https:\/\/www.howtoforge.com\/tutorial\/how-to-run-commands-on-file-or-directory-changes-with-incron-on-ubuntu-16-04\/\" target=\"_blank\" rel=\"noopener\">incron tutorial<\/a>\u00a0and create a script to automatically update your ispserver.pem file, as follows:<\/p>\n<p>Via terminal command, install incron, then create the script file and edit it using nano:<\/p>\n<p class=\"command\">apt install -y incron<br \/>nano \/etc\/init.d\/le_ispc_pem.sh<\/p>\n<p>Add this in the le_ispc_pem.sh:<\/p>\n<pre>#!\/bin\/sh<br\/>### BEGIN INIT INFO<br\/># Provides: LE ISPSERVER.PEM AUTO UPDATER<br\/># Required-Start: $local_fs $network<br\/># Required-Stop: $local_fs<br\/># Default-Start: 2 3 4 5<br\/># Default-Stop: 0 1 6<br\/># Short-Description: LE ISPSERVER.PEM AUTO UPDATER<br\/># Description: Update ispserver.pem automatically after ISPC LE SSL certs are renewed.<br\/>### END INIT INFO<br\/>cd \/usr\/local\/ispconfig\/interface\/ssl\/<br\/>mv ispserver.pem ispserver.pem-$(date +\"%y%m%d%H%M%S\").bak<br\/>cat ispserver.{key,crt} &gt; ispserver.pem<br\/>chmod 600 ispserver.pem<br\/>chmod 600 \/etc\/ssl\/private\/pure-ftpd.pem<br\/>service pure-ftpd-mysql restart<br\/>service monit restart<br\/>service postfix restart<br\/>service dovecot restart<br\/>service nginx restart<\/pre>\n<ul>\n<li>Note some people do not install monit, so they can safely remove it. Do adjust the above script accordingly.<\/li>\n<li>For multi-server setup, do refer to post #203 and add the given scp code in here to automate future update.<\/li>\n<\/ul>\n<p>We then make it executable, add root as an allowed user for incrontab and then edit incrontab file:<\/p>\n<p class=\"command\">chmod +x \/etc\/init.d\/le_ispc_pem.sh<br \/>echo &#8220;root&#8221; &gt;&gt; \/etc\/incron.allow<br \/>incrontab -e<\/p>\n<p>Add this line in it incrontab:<\/p>\n<pre>\/etc\/letsencrypt\/archive\/$(hostname -f)\/ IN_MODIFY .\/etc\/init.d\/le_ispc_pem.sh<\/pre>\n<h2 id=\"restarting-yournbspservices\">Restarting Your\u00a0Services<\/h2>\n<p>I think that is about it for Securing Your Server With Let&#8217;s Encrypt. You may want to restart your web server\u00a0afterwards.<\/p>\n<p class=\"command\">service nginx restart<\/p>\n<p>Remember: if you are using apache, change nginx to apache2 accordingly.<\/p>\n<h2 id=\"leispc\">LE4ISPC<\/h2>\n<p>As an alternative, you\u00a0might want to use\u00a0<a href=\"https:\/\/github.com\/ahrasis\/LE4ISPC\" target=\"_blank\" rel=\"noopener\">LE4ISPC script<\/a> created for this purpose which supports both nginx and apache2 from ISPConfig up to pure-ftpd above except for monit. Before using it, you should already have\u00a0completed the above steps (1-5) and have :<\/p>\n<p>1. Created the website for your server via ISPConfig;<br \/>2. The website accessible online;<br \/>3. ISPConfig SSL enabled (via installation or update);<br \/>4. LE SSL successfully enabled for the website.<\/p>\n<div>\n<p><b>Share this page:<\/b><\/p>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Author:\u00a0ahrasis This tutorial shows how to create and configure a free Let&#8217;s encrypt SSL certificate for the ISPconfig interface (port 8080), the email system (Postfix and Dovecot\/Courier), the FTP server (pure-ftpd) and Monit. The commands\u00a0in this tutorial have been tested on Ubuntu 16.04, they should work for Debian as well. Certain modifications may be necessary &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-2868","post","type-post","status-publish","format-standard","hentry","category-36"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/2868","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=2868"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/2868\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=2868"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=2868"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=2868"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}