How Do You Set up Nginx as an HTTP Load Balancer So Client Requests (from Web Browsers) Do Not Go to Certain Nginx Servers unless Others Are Down?

Problem scenario
You have a web server running Nginx that acts as a reverse proxy server.  On occasion your regular web (Nginx) servers go down.  You want to have one or two web (Nginx) servers that are  reserved as backups exclusively.  You do not want traffic going to these servers unless the main Nginx servers are unavailable (either due to network or server failure).  You can allocate RAM and CPU to these reserved servers on demand. 

In Linux without the Internet, How Do You Enter Left Double Quotes (“) or Right Double Quotes (”)?

Problem scenario
You are trying to search a file for left double quotes and right double quotes (e.g., using a Linux command terminal or a vi editor). How do you enter left double quotes or right double quotes using a keyboard (without copying the apparently italicized double quotes from a web page)?

Solution
Hold Alt, and then enter the sequence 8220 for left double quotes.

How Do You Write a Python Program to Test if a Word is a Substring of Another Word?

Problem scenario
You want to write a program that will test if a pattern is in another word. You are looking for the SQL equivalent of “contains” in Python. How do you test if a string is a substring of another word?

Solution
Use this program:

# Change “micro” and “microsoft” to the substring and string to be searched respectively:

a = “micro”
b = “microsoft”
if a in b:
print(a + ” is in ” + b)
else:
print(a + ” is NOT in ” + b) …

How Do You Find the URL of Your Kubernetes Cluster?

Problem scenario
You want to view the website that is powered by Kubernetes. But you do not know which URL to go to. What should you do from the back-end server with kubectl?

Solution

1. Run this: kubectl get services
With the resulting output, find a name that you want the URL for. (Services have names.) Let’s assume the name was “foobar”.

How Do You Troubleshoot the Error “Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock”?

Problem scenario
You try to run a Docker command, but you get this error: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.29/containers/json?all=1: dial unix /var/run/docker.sock: connect: permission denied

What should you do?

Solution
Have you added the user who was trying to execute the command to the “docker” group?

This command would add the user jdoe to the “docker” group:
sudo usermod -aG docker jdoe

If you ran the above command as the jdoe user,

How Do You Get a PHP Script to Invoke a Bash Command?

Problem scenario
You are trying to get a PHP file to invoke a bash script. When you run it from the command line with “php foobar.php” you just see the content of the PHP file. What do you do to get PHP to invoke a bash script?

Solution
Make sure you have the correct header and closing symbols. Here is the content of foobar.php:

<?php
exec(‘bash /var/www/html/testScript.sh’); …

What Is a docker-compose.yml File?

Question
What is a docker-compose.yml file?

Answer
It is a file used by the docker-compose utility which orchestrates the creation of multiple containers. For microservices, SOA and various stacks of applications (e.g., the LAMP stack), container orchestration is useful. Here are some quotes which help elucidate what docker-compose does:

“Compose is a tool for defining and running multi-container Docker applications.” (Taken from Docker’s website.)

“In order to do something useful with containers,

How Do You Troubleshoot Jenkins Pipelines Not Running when You Try to Execute Them?

Problem scenario
Your Jenkins pipeline jobs will not run. You see “Build Scheduled” when you click on the “Build now” link. But nothing happens. You see an error that your /var/lib/jenkins/ is running low on disk space. You have no access to the back-end of the server that runs Jenkins. What should you do?

Solution
Look at the dashboard view. Next to the date and time of the most recent success of the job (build,

How Do You Use a PowerShell Command to Stop an Azure VM?

Problem scenario
You have a server in Azure you want to turn off. What should you do to stop it?

Solution
Prerequisite
You need to know the server’s name and resource group. You can do this by finding the server in the Azure Portal.

Procedures
Run this command:

Stop-AzureRmVM -ResourceGroupName $nameOfResourceGroup -Name $nameOfVM

# Replace $nameOfResourceGroup with the name of the Resource Group. …