Thursday 14 May 2020

How to Install Let’s Encrypt SSL Certificate with Apache on Ubuntu

This step-by-step tutorial will show you how to install Let’s Encrypt SSL certificate for an Apache server running on Ubuntu 18.04. I’ve created a droplet on DigitalOcean for this example but the steps should be similar AWS and other environments.
Install Apache 2
Login to your droplet with root (or use sudo with all the following commands).
Check if any Ubuntu packages are outdated.
apt update
Upgrade the outdated packages to the latest version.
apt upgrade
Install Apache2
apt install apache2
Start the Apache Server
systemctl start apache2
Check if the Apache server is running
systemctl status apache2
Enable the mod_rewrite package for Apache
sudo a2enmod rewrite
Restart Apache
systemctl restart apache2

Install PHP

Install PHP and restart the Apache server.
apt install php libapache2-mod-php
systemctl restart apache2
php —version

Install the CURL package

Install Curl and restart Apache server
apt install curl
apt install php7.2-curl
systemctl restart apache2

Install Let’s Encrypt on Apache

Install the certbot client that will help us automatically manage (install, renew or revoke) the SSL certificates on the Apache server.

Install Certbot

Install the certbot client and the plugin.
sudo apt update
sudo apt-get install software-properties-common
sudo add-apt-repository universe
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install certbot python-certbot-apache

Install Certbot DNS Plugin

Install the certbot DNS plugin for DigitalOcean. This will automatically add the _acme-challenge TXT DNS records to your domain that are required for authentication. The records are also removed after the certificates are installed.
sudo apt-get install python3-certbot-dns-digitalocean
This will only work if you are using the DigitalOcean Name Servers with your domain.

Create DigitalOcean Credentials File

Go to your DigitalOcean account’s dashboard, choose API and choose “Generate New Token”. Copy the token to your clipboard. Inside the terminal, create a new directory ~/.ssh and create a new file to save the credentials.
vi ~/.ssh/digitalocean.ini
Paste the following line in the credentials file. Replace 1234 with your actual token value.
dns_digitalocean_token = 1234
Save the file and then run chmod to restrict access to the file.
chmod 600 ~/.ssh/digitalocean.ini

Install SSL Certificates

Replace labnol.org with your domain name. This command will install the wildcard SSL certificate for all subdomains and the main domain.
certbot certonly --dns-digitalocean
    --dns-digitalocean-credentials ~/.ssh/digitalocean.ini
    --dns-digitalocean-propagation-seconds 60
    -d "*.labnol.org" -d labnol.org
If the certificate is successfully installed, it will add the certificate and chain in the following directory
/etc/letsencrypt/live/labnol.org/

Test the SSL Certificate

Go to ssllabs.com to test if your new SSL certificate is correctly installed on your domain.

Configure Apache to Use SSL Certificate

Now that the SSL Certificate is installed, we need to enable SSL for the Apache server on Ubuntu.

Enable the SSL module for Apache

OpenSSL is installed with Ubuntu but it is disabled by default. Enable the SSL module and restart Apache to apply the changes.
sudo a2enmod ssl
sudo service apache2 restart

Update Apache Configuration File

Open the default virtual host configuration file /etc/apache2/sites-enabled/000-default.confand paste the following lines. Replace labnol with your domain name.
<VirtualHost *:80>
 RewriteEngine On
 RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
</VirtualHost>
<VirtualHost _default_:443>
 ServerAdmin amit@labnol.org
 ServerName labnol.org
 DocumentRoot /var/www/html

 ErrorLog ${APACHE_LOG_DIR}/error.log
 CustomLog ${APACHE_LOG_DIR}/access.log combined

 SSLEngine on
 SSLCertificateFile /etc/letsencrypt/live/labnol.org/fullchain.pem
 SSLCertificateKeyFile /etc/letsencrypt/live/labnol.org/privkey.pem
</VirtualHost>
Save the file and restart Apache. The SSLCertificateFile and SSLCertificateKeyFile files were saved by certbot in the /etc/letsencrypt/live directory.

Adjust the Firewall

In some cases, you may have to enable Apache on SSL port 443 manually with the following command.
sudo ufw allow "Apache Secure"
Restart Apache. All your HTTP traffic will automatically redirect to the HTTPS version with a 301 permanent redirect.
sudo service apache2 restart

Verify Auto-Renewal Process

Your Let’s Encrypt SSL certificate will auto-expire every 90 days. Go to the /etc/cron.d/ folder and you should see a certbot file. This cron job will automatically renew your SSL certificate if the expiration is within 30 days.
You can also run the following command to verify if the renewal process is correctly setup.
sudo certbot renew --dry-run

A Better Way to Embed PDF Documents in Web Pages

How do you embed a PDF document into your website for inline viewing? One popular option is that you upload the PDF file to an online storage service, something like Google Drive or Microsoft’s OneDrive, make the file public and then copy-paste the IFRAME code provided by these services to quickly embed the document in any website.
Here’s a sample PDF embed code for Google Drive that works across all browsers.
  <iframe frameborder="0" scrolling="no"
     width="640" height="480"
     src="https://drive.google.com/file/d/<<FILE_ID>>/preview">
  </iframe>
This is the most common method for embedding PDFs - it is simple, it just works but the downside is that you have no control over how the PDF files are presented in your web pages.
If you prefer to offer a more customized and immersive reading experience for PDFs in your website, check out the new Adobe View SDK. This is part of the Adobe Document Cloud platform but doesn’t cost a penny.
Here are some unique features that make this PDF embed solution stand out:
  • You can add annotation tools inside the PDF viewer. Anyone can annotate the embedded PDF and download the modified file.
  • If you have embedded a lengthy document with multiple pages, readers can use the thumbnail view to quickly jump to any page.
  • The PDF viewer can be customized to hide options for downloading and printing PDF files.
  • There’s built-in analytics so you know how many people saw your PDF file and how they interacted with the document.
  • And my favorite feature of ViewSDK is the inline embed mode. Let me explain that in detail.

Display PDF Pages Inline like Images and Videos

In Inline Mode, and this is unique to Adobe View SDK, all pages of the embedded PDF document are displayed at once so your site visitors do not have to scroll another document with the parent web page. The PDF controls are hidden from the user and the PDF pages blend with images and other HTML content on your web page.
To learn more, check this live demo - here the PDF document contains 7 pages but all are displayed at once like one long web page thus offering smooth navigation.

 How to Embed PDFs with the Adobe View SDK

It does take a few extra steps to use the View SDK. Go to adobe.io and create a new set of credentials for your website. Please note that credentials are valid for one domain only so if you have multiple websites, you’d need a different set of credentials for them.
Next, open the playground and generate the embed code. You need to replace the clientId with your set of credentials. The url in the sample code should point to the location of your PDF file.
<div id="adobe-dc-view" style="width: 800px;"></div>
<script src="https://documentcloud.adobe.com/view-sdk/main.js"></script>
<script type="text/javascript">
    document.addEventListener("adobe_dc_view_sdk.ready", function () {
        var adobeDCView = new AdobeDC.View({
            clientId: "<<YOUR_CLIENT_ID>>",
            divId: "adobe-dc-view"
        });
        adobeDCView.previewFile({
            content: { location: { url: "<<PDF Location>>" } },
            metaData: { fileName: "<<PDF File Name>>" }
        }, {
            embedMode: "IN_LINE",
            showDownloadPDF: false,
            showPrintPDF: false
        });
    });
</script>

How to Create Forms that Allow File Uploads to Google Drive

With File Upload Forms (demo) for Google Sheets, you can receive large files of any size from anyone directly in your Google Drive. You can automatically send email confirmations to notify the form submitter. The forms can be created inside Google Sheets using the built-in drag-n-drop form builder and the forms can have CAPTCHAs, e-signature, multiple file uploads, password protection and more.
Unlike the file uploads feature in Google Forms, the form respondents do not require a Google account to uploads files through your form.

Receive Files from Anyone in Google Drive

A school teacher may want to build forms for students to upload assignments and the files are automatically saved to her Google Drive but in separate student folders. The HR team may want an online form where job applicants can upload their resumes in PDF or Word format. Business can build forms with eSignatures that respondents can sign on their desktops and mobile phones.
Google Forms do allow file uploads but the respondents need to be signed into their Google accounts before they can upload files. File Upload Forms impose no such limitations - anyone can upload files to your Google Drive. They may not have a Google account and they’ll still be able to use your Drive uploader forms.

File Upload Forms - Getting Started

Here’s a step-by-step guide on how you can build your own File Upload Forms in a few minutes. Or watch the YouTube video to get started.

Step 1. Copy the Google Sheet for File Upload Forms

The File Upload Form is written in Google Scripts and the code needs to be attached to your Google Sheet for it to work.
To get started, go to forms.studio/copy and click the “Copy” button to create a copy of the Google Sheet template to your Google Drive. This sheet includes the form builder, email designer and it will also be storing your form responses just like Google Forms responses are stored inside Google Sheets.

Step 2. Deploy the Uploader form as Web App

Inside your Google Spreadsheet, go to Tools -> Script Editor to open the Google Script editor. Don’t worry, you don’t have to write a single line of code, you only have to deploy this script as a web app so anyone can access your form via a simple web URL.
Go to Publish -> Deploy as Web App, choose Me under Execute the app as, choose Anyone, even Anonymous under Who has access to the web app and click the Deploy button.
You may have to authorize the script once since it has to do all the operations - like sending emails, uploading files - on your behalf.
Also, if you get the “App Not Verified” screen, just click on the Advanced link and choose “Go to File Upload Forms” to continue. While this step is optional, you can submit your app to Google for verification and they’ll drop the ‘not verified’ warning.

Step 3. Design the File Uploader Form

Switch to the Google Sheet, expand the File Upload Forms menu (near Help) and choose Edit Form. It will launch a simple but powerful drag-n-drop form builder right inside your Google Sheets.
Your forms can have multiple file upload fields, eSignatures, date, time picker, and all the standard form fields. Use the Rich HTML field to embed YouTube videos, Google Maps, SoundCloud MP3s, Google Slide presentations, Images or any HTML content.
You can also add data validation rules to various form fields using simple regular expressions. The file upload fields can be configured to accept single or multiple files. You can also limit uploads to specific types like images, videos, zip, and more.

Step 4. Customize the Form’s Settings

After your form is designed, go back to the File Upload Forms menu and choose Configure Form. It will open a sidebar in your Google Sheet where you can customize the form and Google Drive settings.
The confirmation message can include place-markers - form fields enclosed inside double curly braces like {{name}} - for personalized messages. You can also place a URL inside the Redirect option and respondents would be redirected to that website after submitting the form.
In the advanced settings section, click the Select Folder button to choose the parent folder in your Google Drive where all the files would be saved. You can also specify a sub-folder path for storing files and this path can be dynamic - \\{{Country}}\\{{City}} - based on form answers.
You can also change color schemes, track visits to your form with Google Analytics and protect your forms with Google CAPTCHA and passwords.

Step 5. Send Confirmation Emails

With File Upload Forms, you can send email notifications when people submit the form. The emails can be personalized by including the form fields in the email subject and message body.
Use the special {{All Answers}} place marker in the message body to include a summary of the form response in a neat table. The TO, CC or BCC field can include the {{question title}} where you ask for the email address and it will be replaced with the actual value in the form response.

How to Determine if your Mobile Phone will work in Another Country?



You are planning to buy a cell phone from an online shopping site of another country but are not too sure if that phone will work with the mobile networks of your country. Or consider a slightly different scenario. You are travelling but how do you determine if your existing cellphone will be compatible with carriers of the foreign country?

Will that Cell Phone Work in my Country?

Well, there are basically two factors that may help you determine if a mobile phone will work with cellular operators of another country or not. Here they are:
1. GSM and CDMA are the two most prevalent standards in the mobile world. As a first step, determine the technology (GSM or CDMA) used by the mobile carrier of the foreign country where you are planning to use your phone.
Wikipedia has dedicated sections - see pages for IndiaEurope and Asia Pacific countries - that list the standards used by various carriers of a particular country. If that carrier is on GSM, you would need a GSM-compliant mobile phone and the device should be unlocked meaning it should be able to accept SIM cards of other carriers.
2. The other important factor is the frequency band  that carriers are using in the country where you are travelling to.
For instance, mobile networks in India use the 900 MHz and 1800 MHz frequency bands while GSM carriers in America operate on 850 MHz and 1900 MHz frequencies. Thus, if you are planning to buy a mobile phone from Amazon.com for use in India, the phone should support the 900 / 1800 MHz frequencies.
You can use the Phone Finder database at GSM Arena  to determine the 2G and 3G frequency bands that are supported by your mobile phone. Then check the mobile operator’s website (or Wikipedia) to determine the frequency bands they are using for their 2G and 3G networks. If the frequencies match, your phone should be compatible with that mobile network.
To summarize, find the frequencies supported by your cellular operator and compare them with the frequencies listed in the technical specifications of your mobile phone. They should match for the phone to be compatible. A quad-band unlocked GSM phone will be compatible with most GSM networks worldwide.