Posted on

How Shitty Start-Com SSL, Go With Let-encrypt, Less Shady COMPLETELY FREE AND AUTOMATED!!

Hey guys, I may not have a large audience, but I need to correct previous recommendations for this shitty ass company known as Start-Com.

First, they are sanction for what some would consider to be shady activity, I am glad they are working to rectify the issue, however I have not seen a backup scheme they should have implement to prevent an issue as this. My Certificate that I generated when I had paid them for Verification (Which is a Whole shitty process unto itself if you move around because of Education or work), doesn’t work, here is a link to their faux pa:

Google to Distrust WoSign, StartCom Certs in 2017

I was an avid  fan, yea the Verification was a bit tedious, however it wasn’t as flexible as I would assume it should be, with many different forms of verfify myself, who I am, where I am currently established, with documents such as my SSN, Drivers Licenses old and new, electric bills, Email verification, They stated that in the interim due to the issue that they would provide SSLs free of charge.

So now I am out of  site protection, try to fix the issue for a few smaller things, and yet they still insist on further verification of making a payment of 0.50 USD to verify who I am via PayPal.

Besides the fact I don’t have .50 in my Paypal accout, and I am overdrafted till later is none of your financial concern. Asking to provide money up front isn’t free, to have it refunded later is to defeat the purpose of something being free.

So, here is a guide to Install LetsEncrypt on CentOS 7 :

Step 1 — Install the Certbot Let’s Encrypt Client

The first step to using Let’s Encrypt to obtain an SSL certificate is to install the certbot software on your server. Currently, the best way to install this is through the EPEL repository.

Enable access to the EPEL repository on your server by typing:

  • sudo yum install epel-release

Once the repository has been enabled, you can obtain the certbot package by typing:

  • sudo yum install certbot

The certbot Let’s Encrypt client should now be installed and ready to use.

Step 2 — Obtain a Certificate

Let’s Encrypt provides a variety of ways to obtain SSL certificates, through various plugins. Unlike the Apache plugin, which is covered in a different tutorial, most of the plugins will only help you with obtaining a certificate which you must manually configure your web server to use. Plugins that only obtain certificates, and don’t install them, are referred to as “authenticators” because they are used to authenticate whether a server should be issued a certificate.

We’ll show you how to use the Webroot plugin to obtain an SSL certificate.

How To Use the Webroot Plugin

The Webroot plugin works by placing a special file in the /.well-known directory within your document root, which can be opened (through your web server) by the Let’s Encrypt service for validation. Depending on your configuration, you may need to explicitly allow access to the /.well-known directory.

If you haven’t installed Nginx yet, you can do so now. The EPEL repository should already be enabled from the previous section, so you can install Nginx by typing:

  • sudo yum install nginx

To ensure that the directory is accessible to Let’s Encrypt for validation, let’s make a quick change to our default Nginx server block. The default Nginx configuration file allows us to easily add directives to the port 80 server block by adding files in the /etc/nginx/default.d directory.

If you’re using the default configuration, create a new file called le-well-known.conf and open it for editing with this command:

  • sudo vi /etc/nginx/default.d/le-well-known.conf

Then paste in these lines:

/etc/nginx/default.d/le-well-known.conf
location ~ /.well-known {
        allow all;
}

Save and exit.

Check the configuration for syntax errors by typing:

  • sudo nginx -t

If no errors were reported, start or restart Nginx with this command:

  • sudo systemctl restart nginx

If you aren’t using the default server block, you will need to look up what your document root is set to by looking for the root directive in your default Nginx server block. This is the value that Let’s Encrypt requires, as webroot-path, when using the Webroot plugin. The default root is /usr/share/nginx/html.

Next, make sure port 80 and 443 are open in your firewall. If you are not running a firewall, you can skip ahead.

If you have a firewalld firewall running, you can open these ports by typing:

  • sudo firewall-cmd –add-service=http
  • sudo firewall-cmd –add-service=https
  • sudo firewall-cmd –runtime-to-permanent

If have an iptables firewall running, the commands you need to run are highly dependent on your current rule set. For a basic rule set, you can add HTTP and HTTPS access by typing:

  • sudo iptables -I INPUT -p tcp -m tcp –dport 80 -j ACCEPT
  • sudo iptables -I INPUT -p tcp -m tcp –dport 443 -j ACCEPT

Now that we know our webroot-path, we can use the Webroot plugin to request an SSL certificate with these commands. Here, we are also specifying our domain names with the -d option. If you want a single cert to work with multiple domain names (e.g. example.com and www.example.com), be sure to include all of them. Also, make sure that you replace the highlighted parts with the appropriate webroot path and domain name(s):

  • sudo certbot certonly -a webroot –webroot-path=/usr/share/nginx/html -d example.com -d www.example.com

After certbot initializes, you will be prompted for some information. The exact prompts may vary depending on if you’ve used certbot before, but we’ll step you through the first time.

At the prompt, enter an email address that will be used for notices and lost key recovery:

Email prompt

Then you must agree to the Let’s Encrypt Subscribe Agreement. Select Agree:

Let's Encrypt Subscriber's Agreement

If everything was successful, you should see an output message that looks something like this:

Output:
IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at
   /etc/letsencrypt/live/example.com/fullchain.pem. Your
   cert will expire on 2016-03-15. To obtain a new version of the
   certificate in the future, simply run Let's Encrypt again.
 - If you lose your account credentials, you can recover through
   e-mails sent to [email protected]
 - Your account credentials have been saved in your Let's Encrypt
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Let's
   Encrypt so making regular backups of this folder is ideal.
 - If like Let's Encrypt, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

You will want to note the path and expiration date of your certificate, which was highlighted in the example output.

Note: If you receive an error like Failed to connect to host for DVSNI challenge, recheck your server’s firewall to make sure it is configured to allow TCP traffic on port 80 and 443.

Note: If your domain is routing through a DNS service like CloudFlare, you will need to temporarily disable it until you have obtained the certificate.

Certificate Files

After obtaining the cert, you will have the following PEM-encoded files:

  • cert.pem: Your domain’s certificate
  • chain.pem: The Let’s Encrypt chain certificate
  • fullchain.pem: cert.pem and chain.pem combined
  • privkey.pem: Your certificate’s private key

It’s important that you are aware of the location of the certificate files that were just created, so you can use them in your web server configuration. The files themselves are placed in a subdirectory in /etc/letsencrypt/archive. However, the certbot Let’s Encrypt client creates symbolic links to the most recent certificate files in the /etc/letsencrypt/live/your_domain_name directory. Because the links will always point to the most recent certificate files, this is the path that you should use to refer to your certificate files.

You can check that the files exist by running this command (substituting in your domain name):

  • sudo ls -l /etc/letsencrypt/live/your_domain_name

The output should be the four previously mentioned certificate files. In a moment, you will configure your web server to use fullchain.pem as the certificate file, and privkey.pem as the certificate key file.

Generate Strong Diffie-Hellman Group

To further increase security, you should also generate a strong Diffie-Hellman group. To generate a 2048-bit group, use this command:

  • sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048

This may take a few minutes but when it’s done you will have a strong DH group at /etc/ssl/certs/dhparam.pem.

Step 3 — Configure TLS/SSL on Web Server (Nginx)

Now you must edit the Nginx configuration to use the Let’s Encrypt certificate files. The default Nginx configuration on CentOS is pretty open-ended but we will create a new server block that uses SSL/TLS and listens on port 443. Then we’ll configure the default (HTTP on port 80) server block to redirect to the HTTPS-enabled server block.

By default, additional server block configuration can be placed in /etc/nginx/conf.d. Create a new file called ssl.conf and open it for editing with this command:

  • sudo vi /etc/nginx/conf.d/ssl.conf

Then paste this configuration in. Be sure to change every instance of example.com, all four, with your own domain name:

/etc/nginx/conf.d/ssl.conf
server {
        listen 443 http2 ssl;

        server_name example.com www.example.com;

        ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

        ########################################################################
        # from https://cipherli.st/                                            #
        # and https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html #
        ########################################################################

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
        ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
        ssl_ecdh_curve secp384r1;
        ssl_session_cache shared:SSL:10m;
        ssl_session_tickets off;
        ssl_stapling on;
        ssl_stapling_verify on;
        resolver 8.8.8.8 8.8.4.4 valid=300s;
        resolver_timeout 5s;
        # Disable preloading HSTS for now.  You can use the commented out header line that includes
        # the "preload" directive if you understand the implications.
        #add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
        add_header Strict-Transport-Security "max-age=63072000; includeSubdomains";
        add_header X-Frame-Options DENY;
        add_header X-Content-Type-Options nosniff;

        ##################################
        # END https://cipherli.st/ BLOCK #
        ##################################

        ssl_dhparam /etc/ssl/certs/dhparam.pem;

        location ~ /.well-known {
                allow all;
        }

        # The rest of your server block
        root /usr/share/nginx/html;
        index index.html index.htm;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }
}

To set up Nginx SSL securely, in the configuration above we used the recommendations by Remy van Elston the Cipherli.st site. This site is designed to provide easy-to-consume encryption settings for popular software. You can read more about his decisions regarding the Nginx choices here.

Note: The default suggested settings on Cipherli.st offer strong security. Sometimes, this comes at the cost of greater client compatibility. If you need to support older clients, there is an alternative list that can be accessed by clicking the link on the link labeled “Yes, give me a ciphersuite that works with legacy / old software.”

The compatibility list can be used instead of the default suggestions in the configuration above between the two comment blocks. The choice of which config you use will depend largely on what you need to support.

There are a few pieces of the configuration that you may wish to modify. First, we added our preferred DNS resolver for upstream requests. We used Google’s for this guide, but you can change this if you have other preferences.

Finally, you should take take a moment to read up on HTTP Strict Transport Security, or HSTS, and specifically about the “preload” functionality. Preloading HSTS provides increased security, but can have far reaching consequences if accidentally enabled or enabled incorrectly. In this guide, we did not preload the settings, but you can modify that if you are sure you understand the implications.

Modify the rest of the server block to suit your needs.

Save and exit. This configures Nginx to use SSL, and tells it to use the Let’s Encrypt SSL certificate that we obtained earlier. Also, the SSL options specified here ensure that only the most secure protocols and ciphers will be used. Note that this example configuration simply serves the default Nginx page, so you may want to modify it to meet your needs.

Next, we’ll configure Nginx to redirect HTTP requests on port 80 to HTTPS on port 443.

The default Nginx configuration file allows us to easily add directives to the port 80 server block by adding files in the /etc/nginx/default.d directory. Create a new file called ssl-redirect.conf and open it for editing with this command:

  • sudo vi /etc/nginx/default.d/ssl-redirect.conf

Then paste in this line:

/etc/nginx/default.d/ssl-redirect.conf
    return 301 https://$host$request_uri;

Save and exit. This configures the HTTP on port 80 (default) server block to redirect incoming requests to HTTPS.

Now, check the configuration for syntax errors:

  • sudo nginx -t

If no errors are found, restart Nginx:

  • sudo systemctl restart nginx

You will also want to enable Nginx, so it starts when your server boots:

  • sudo systemctl enable nginx

The Let’s Encrypt TLS/SSL certificate is now in place. At this point, you should test that the TLS/SSL certificate works by visiting your domain via HTTPS in a web browser.

You can use the Qualys SSL Labs Report to see how your server configuration scores:

In a web browser:
https://www.ssllabs.com/ssltest/analyze.html?d=example.com

This SSL setup should report an A rating.

Step 4 — Set Up Auto Renewal

Let’s Encrypt certificates are valid for 90 days, but it’s recommended that you renew the certificates every 60 days to allow a margin of error. At the time of this writing, automatic renewal is still not available as a feature of the client itself, but you can manually renew your certificates by running the certbot Let’s Encrypt client with the renew option.

To trigger the renewal process for all installed domains, run this command:

  • sudo certbot renew

Because we recently installed the certificate, the command will only check for the expiration date and print a message informing that the certificate is not due to renewal yet. The output should look similar to this:

Output:
Saving debug log to /var/log/letsencrypt/example.com

-------------------------------------------------------------------------------
Processing /etc/letsencrypt/renewal/example.com.conf
-------------------------------------------------------------------------------
Cert not yet due for renewal

The following certs are not due for renewal yet:
  /etc/letsencrypt/live/example.com/fullchain.pem (skipped)
No renewals were attempted.

Notice that if you created a bundled certificate with multiple domains, only the base domain name will be shown in the output, but the renewal should be valid for all domains included in this certificate.

A practical way to ensure your certificates won’t get outdated is to create a cron job that will periodically execute the automatic renewal command for you. Since the renewal first checks for the expiration date and only executes the renewal if the certificate is less than 30 days away from expiration, it is safe to create a cron job that runs every week or even every day, for instance.

Let’s edit the crontab to create a new job that will run the renewal command every week. To edit the crontab for the root user, run:

  • sudo crontab -e

Add the following lines:

crontab entry
30 2 * * 1 /usr/bin/certbot renew >> /var/log/le-renew.log
35 2 * * 1 /usr/bin/systemctl reload nginx

Save and exit. This will create a new cron job that will execute the certbot renew command every Monday at 2:30 am, and reload Nginx at 2:35am (so the renewed certificate will be used). The output produced by the command will be piped to a log file located at /var/log/le-renewal.log.

For more information on how to create and schedule cron jobs, you can check our How to Use Cron to Automate Tasks in a VPS guide.

Conclusion

That’s it! Your web server is now using a free Let’s Encrypt TLS/SSL certificate to securely serve HTTPS content.

Posted on

How To Make php-fpm Listen On Both Tcp And Unix Socket?

Apache, CGI, HTTP, HTTPS, Linux, modules, php Add comments

I need to make php-fpm listening on both tcp/UNIX socket, and this is how it done.
(this was not pretty workaround i guess, but it work ? )
first download php rpm source

Compile and install
$ rpmbuild –rebuild php-5.3.3-2.el5.src.rpm
$ sudo rpm -Uvh /path/to/RPMS/php-*
Configuring the default php-fpm for using tcp socket
Edit www.conf
$ sudo nano /etc/php-fpm.d/www.conf
Find line containing

listen = 127.0.0.1:9000
We can make it listening to port what ever we desire, ie 9001 etc
Start php-fpm first instance
$ sudo service php-fpm start
Configuring php-fpm for using unix socket
$ sudo cp /etc/php-fpm.conf /etc/php-fpm2.conf

$ sudo cp -rp /etc/php-fpm.d /etc/php-fpm2.d
Edit /etc/php-fpm2.conf
include=/etc/php-fpm2.d/*.conf

pid = /var/run/php-fpm/php-fpm2.pid

error_log = /var/log/php-fpm/error2.log
Edit /etc/php-fpm2.d/www.conf
listen = /tmp/php-fpm.sock

php_admin_value[error_log] = /var/log/php-fpm/www-error2.log

Copy The start up script in /etc/init.d/
$ sudo cp /etc/init.d/php-fpm /etc/php-fpm2
Make a view changes on php-fpm2 init script

01
#! /bin/sh
02
#
03
# chkconfig: – 84 16
04
# description: PHP FastCGI Process Manager
05
# processname: php-fpm
06
# config: /etc/php-fpm.conf
07
# pidfile: /var/run/php-fpm/php-fpm.pid
08

09
# Standard LSB functions
10
#. /lib/lsb/init-functions
11

12
# Source function library.
13
. /etc/init.d/functions
14

15
# Check that networking is up.
16
. /etc/sysconfig/network
17

18
if [ “$NETWORKING” = “no” ]
19
then
20
exit 0
21
fi
22

23
RETVAL=0
24
prog=”php-fpm2″
25
pidfile=${PIDFILE-/var/run/php-fpm/php-fpm2.pid}
26
lockfile=${LOCKFILE-/var/lock/subsys/php-fpm2}
27

28
start () {
29
echo -n $”Starting $prog: ”
30
daemon –pidfile ${pidfile} php-fpm2 –fpm-config /etc/php-fpm2.conf
31
RETVAL=$?
32
echo
33
[ $RETVAL -eq 0 ] && touch ${lockfile}
34
}
35
stop () {
36
echo -n $”Stopping $prog: ”
37
killproc -p ${pidfile} php-fpm2
38
RETVAL=$?
39
echo
40
if [ $RETVAL -eq 0 ] ; then
41
rm -f ${lockfile} ${pidfile}
42
fi
43
}
44

45
restart () {
46
stop
47
start
48
}
49

50
# See how we were called.
51
case “$1″ in
52
start)
53
start
54
;;
55
stop)
56
stop
57
;;
58
status)
59
status -p ${pidfile} php-fpm2
60
RETVAL=$?
61
;;
62
restart|reload|force-reload)
63
restart
64
;;
65
condrestart|try-restart)
66
[ -f ${lockfile} ] && restart || :
67
;;
68
*)
69
echo $”Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart|try-restart}”
70
RETVAL=2
71
;;
72
esac
73

74
exit $RETVAL
Don’t forget to copy php-fpm binary in /usr/sbin/ driectory

1
$ sudo cp /usr/sbin/php-fpm /usr/sbin/php-fpm2
Start php-fpm2 unix socket instance

1
$ sudo service php-fpm2 start
Check it out if it’s successfuly listening on both tcp/unix socket

1
$ sudo netstat -pln | grep php-fpm
It’ll look like this

1
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 1265/php-fpm
2
unix 2 [ ACC ] STREAM LISTENING 888664697 27700/php-fpm2 /tmp/php-fpm.sock
Finnaly, make all the work we’ve done get fixed

1
$ sudo chkconfig php-fpm on
2
$ sudo chkconfig php-fpm2 on
We can use it as backends for nginx upstream module

01
http {
02
……
03
……
04
upstream backend {
05
fair; # we can use upstream fair module here
06
server 127.0.0.1:9000;
07
server unix:/tmp/php-fpm.sock;
08
}
09
……
10
……
11
server {
12
location ~ .php$ {
13
fastcgi_pass backend;
14
fastcgi_index index.php;
15
…….
16
…….
17
include fastcgi_params;
18
}
19
……
20
……
21
}
22
}
that’s it, i hope it work on you too ?

Posted on

How to convert install.esd to install.wim

In this tutorial I will show you how to convert an install.esd to an install.wim so you can use it to install windows onto a usb external hard drive. You will need to be on Windows to do this as it uses the Windows command prompt.

 

First you will need to download this. It is the command line tool you will be using.

1. Put your install.esd in C: (your C drive)

2. Extract ESD2WIM-WIM2ESD-v2.zip by double clicking on it and extracting it to the same location.(It does not matter where this is placed.)

3. Go into ESD2WIM-WIM2ESD-v2 folder and right click on ESD2WIM-WIM2ESD and run as administrator.

 

4. The command prompt will ask you to enter the location of where the install.esd file is. It should be C:install.esd.

At the top it should show Detected ESD File contains x indexes (x being the number of indexes)

The first index should work. In my case there was only one index so we will use that one.

5.Type: 1 and it will start to convert and export the install.wim. You do not need to press enter once you type 1 it will start the conversion.

Once that is done you should see the completed install.wim in the ESD2WIM-WIM2ESD-v2 folder.

Posted on

How to force HTTPS using the .htaccess file

To force all web traffic to use HTTPS insert the following lines of code in the .htaccess file in your website’s root folder.

Important:If you have existing code in your .htaccess, add this above where there are already rules with a similar starting prefix.

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

Be sure to replace www.example.com with your actual domain name.

To force a specific domain to use HTTPS, use the following lines of code in the .htaccess file in your website’s root folder:

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

Make sure to replace example\.com with the domain name you’re trying force to https. Additionally, you need to replace www.example.com with your actual domain name.

If you want to force SSL on a specific folder you can insert the code below into a .htaccess file placed in that specific folder:

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} folder 
RewriteRule ^(.*)$ https://www.example.com/folder/$1 [R,L]

Make sure you change the folder reference to the actual folder name. Then be sure to replace www.example.com/folderwith your actual domain name and folder you want to force the SSL on.

Posted on

WordPress wp-cron.php Excessive CPU and/RAM usage

WordPress uses a file called wp-cron.php as a virtual cron job, or scheduled task in order to automate things like publishing scheduled posts, checking for plugin or theme updates, sending email notifications and more.

By default WordPress is setup to call wp-cron.php everytime someone visits your WordPress website when a scheduled task is present, to basically ask “is it time to do anything yet?”.

On low traffic sites this is perfectly fine, but when visitors roll in, checking multiple times for scheduled tasks can be very inefficient and lead to resource usage problems for your server, plus make your website load slower.

Continue reading WordPress wp-cron.php Excessive CPU and/RAM usage

Posted on

SpamAssassin

To enable or disable SpamAssassin:

  1. Log into cPanel.
  2. In the Mail section, click the SpamAssassin icon.
  3. In the gray box, click Enable SpamAssassin to enable; or click Disable SpamAssassin to disable.

Depending on the option you selected, you will receive a confirmation message on the next page stating that SpamAssassin was either enabled or disabled.

Continue reading SpamAssassin

Posted on

Setting Up Private Nameservers in WHM/cPanel

Setting up your own private nameservers on a cPanel server has many benefits, most importantly enabling all of cPanel’s built in DNS tools which can make DNS changes much easier.

This guide will show you how to set up and register new private nameservers on a cPanel server using the WHM (Web Host Manager) interface.
Continue reading Setting Up Private Nameservers in WHM/cPanel