{"id":405,"date":"2020-10-14T15:31:44","date_gmt":"2020-10-14T15:31:44","guid":{"rendered":"https:\/\/dft.wiki\/?p=405"},"modified":"2021-04-06T15:01:22","modified_gmt":"2021-04-06T15:01:22","slug":"wordpress-configuration-tips-and-tricks","status":"publish","type":"post","link":"https:\/\/dft.wiki\/?p=405","title":{"rendered":"WordPress Configuration and Security Tips"},"content":{"rendered":"<p>I just installed WordPress on your server and what is the first concern? Security!<\/p>\n<p>We will cover the following points:<\/p>\n<ul>\n<li>Fail2Ban<\/li>\n<li>WP Fail2Ban<\/li>\n<li>2FAS Prime<\/li>\n<li>Loginizer<\/li>\n<li>Disable XML-RPC-API<\/li>\n<li>WP Activity Log<\/li>\n<li>Manual Configurations<\/li>\n<li>Multi-Site<\/li>\n<li>Multi-Domain<\/li>\n<li>WP MU Domain Mapping<\/li>\n<li>WAF and CDN<\/li>\n<li>Duplicator<\/li>\n<\/ul>\n<p>If you have control of your server (like a VPS, not Godaddy, etc) it is mandatory to have Fail2Ban securing SSH but it also can be used with WordPress. If it is not set up yet, read the following post about Increasing Security with Fail2Ban on Ubuntu 20.4 [<a href=\"https:\/\/dft.wiki\/?p=401\">Link<\/a>].<\/p>\n<p>Inside your WordPress Dashboard, search for and install the plugin <strong>WP Fail2Ban<\/strong> (by Charles Lecklider) and activate it.<\/p>\n<p>Then go to your Linux terminal and add the Filter and the Jail:<\/p>\n<pre>sudo curl https:\/\/plugins.svn.wordpress.org\/wp-fail2ban\/trunk\/filters.d\/wordpress-hard.conf &gt; \/etc\/fail2ban\/filter.d\/wordpress.conf<\/pre>\n<p>If it does not work get the file here [<a href=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2020\/10\/wordpress.zip\">wordpress.conf<\/a>]. Place it in: \/etc\/fail2ban\/filter.d\/<\/p>\n<p>Next, edit the jail file:<\/p>\n<pre>sudo nano \/etc\/fail2ban\/jail.d\/wordpress.conf<\/pre>\n<p>Add the following configuration to the newly created file:<\/p>\n<pre>[wordpress]\r\nenabled = true\r\nfilter = wordpress\r\nlogpath = \/var\/log\/auth.log\r\nport = http,https<\/pre>\n<p>Restart the Fail2Ban service:<\/p>\n<pre>sudo service fail2ban restart<\/pre>\n<p>Test if you can try and fail to authenticate in your WordPress before you consider being protected. In my case did not work right away and I had to troubleshoot it.<\/p>\n<p>Implement 2FA (Two Factor Authentication) with <strong>2FAS Prime<\/strong> (by Two Factor Authentication Service Inc) plug-in.<\/p>\n<p>After go to the option Users on the left menu and enable 2FA to your user. It is serv explanatory and only requires the Google Authenticator to scan the QR Code and type the generated temporary code.<\/p>\n<p>A quick analysis with <strong>Loginizer<\/strong> (by Softaculous). After installing and enabling it, find its menu on the left side.<\/p>\n<p>On the first page, a quick analysis of your environment may reveal opportunities such as changing the privileges to file to prevent modification:<\/p>\n<pre>sudo chmod 444 \/var\/www\/wordpress\/wp-config.php<\/pre>\n<p>Now you could disable, delete, or just leave this plug-in there.<\/p>\n<p>If you do not use any API that requires XML-RPC, disable this feature because this could be a vulnerability.<\/p>\n<p>Install and activate the <strong>Disable XML-RPC-API<\/strong> (by Neatmarketing) plug-in. No further action needs to be taken.<\/p>\n<p>If the website will have many users it is recommended to install the plug-in <strong>WP Activity Log<\/strong> (by WP White Security). It will provide relevant information about user&#8217;s activities.<\/p>\n<p>Manually append the following line to the wp-config.php to prevent file editing:<\/p>\n<pre>sudo nano \/var\/www\/wordpress\/.htaccess<\/pre>\n<p>Add the content:<\/p>\n<pre>Options -Indexes<\/pre>\n<p>Configure Apache:<\/p>\n<pre>sudo nano \/etc\/apache2\/apache2.conf<\/pre>\n<p>Make sure the .htaccess files will override the configurations:<\/p>\n<pre>&lt;Directory \/var\/www\/&gt;\r\n...\r\n     <strong>AllowOverride All\r\n<\/strong>     ServerSignature Off\r\n...\r\n&lt;\/Directory&gt;<\/pre>\n<p>As a manual alternative to disable the <strong>xmlrpc.php<\/strong> file append the following to the <strong>.htaccess<\/strong>:<\/p>\n<pre># BEGIN Disable XML-RPC.PHP\r\n\r\n&lt;Files xmlrpc.php&gt;\r\nOrder Deny,Allow\r\nDeny from all\r\n&lt;\/Files&gt;\r\n\r\n# END Disable XML-RPC.PHP<\/pre>\n<p>Also, disable the execution of PHP files on the upload directory.<\/p>\n<pre>sudo nano \/var\/www\/wordpress\/wp-content\/uploads\/.htaccess<\/pre>\n<p>Add the content:<\/p>\n<pre>&lt;Files *.php&gt;\r\ndeny from all\r\n&lt;\/Files&gt;<\/pre>\n<p>Restart the Apache.<\/p>\n<pre>sudo chmod 444 \/var\/www\/wordpress\/.htaccess\r\nsudo chmod 444 \/var\/www\/wordpress\/wp-content\/uploads\/.htaccess\r\nsudo chown www-data: -R \/var\/www\/\r\nsudo systemctl restart apache2<\/pre>\n<p>If the purpose of this server is to host multiple websites enable the <strong>Multi-Site<\/strong>. It will create a network where many websites can be created and managed on a single instance of WordPress.<\/p>\n<p>The multiple sites would have one of the following address schemas:<\/p>\n<p style=\"padding-left: 40px;\">example.com\/site1<br \/>\nexample.com\/site2<\/p>\n<p style=\"padding-left: 40px;\">OR<\/p>\n<p style=\"padding-left: 40px;\">site1.example.com<br \/>\nsite2.example.com<\/p>\n<p>It can be better customized using <strong>Multi-Domain<\/strong> to be allowed to use multiple domain addresses:<\/p>\n<p style=\"padding-left: 40px;\">example.com<br \/>\nanotherexample.com<\/p>\n<pre>sudo nano \/var\/www\/wordpress\/wp-config.php<\/pre>\n<p>Append the following lines:<\/p>\n<pre>\/* Multisite *\/\r\ndefine('WP_ALLOW_MULTISITE', true);<\/pre>\n<p>Go you the WP-Admin and navigate to Tools &gt; Network Setup and select the option for subdomains.<\/p>\n<p>On the next page, the configuration for the <strong>.htaccess<\/strong> will be shown. Just copy and paste.<\/p>\n<p>Refresh the browser and a new option will show up on the top menu.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1711\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2020\/10\/Screenshot-from-2021-04-06-10-23-36.png\" alt=\"\" width=\"312\" height=\"40\" srcset=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2020\/10\/Screenshot-from-2021-04-06-10-23-36.png 312w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2020\/10\/Screenshot-from-2021-04-06-10-23-36-300x38.png 300w\" sizes=\"auto, (max-width: 312px) 100vw, 312px\" \/><\/p>\n<p>The multi-domain functional works better with the plug-in <strong>WordPress MU Domain Mapping<\/strong> (by Donncha O Caoimh).<\/p>\n<p>It is also a very good practice to implement a Web Application Firewall (WAF) on the server or over a third-party Content Delivery Network (CDN).<\/p>\n<p>A recommended WAF plug-in is <strong>Wordfence Security &#8211; Firewall &amp; Malware Scan<\/strong> (by Wordfence). And Cloud Flair [<a href=\"https:\/\/www.cloudflare.com\/\">Link<\/a>] is a well know CDN provider that offers free services plus additional high-end paid features.<\/p>\n<p>And for backing up of migrating websites the recommended plug-in is the <strong>Duplicator<\/strong> (by Snap Creek).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I just installed WordPress on your server and what is the first concern? Security! We [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-405","post","type-post","status-publish","format-standard","hentry","category-web"],"_links":{"self":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/405","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=405"}],"version-history":[{"count":10,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/405\/revisions"}],"predecessor-version":[{"id":1714,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/405\/revisions\/1714"}],"wp:attachment":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=405"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=405"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=405"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}