Setup hydroMazing Smart Garden System

cropped-hydromazing_smart_garden_system

Setup and Use hydroMazing

  • The Controller ( Arduino Nano ) uses 433MHz Transmitter to send codes to remote-controlled AC Outlets or can connect directly via a transistor, MOSFET, or relay.
  • Web Services Module ( Raspberry Pi ).
    • Optional Web-Camera ( USB Web-Camera ).
  • Optional  ( connect directly via a transistor, MOSFET, or relay.  Supports additional sensors: E.C., pH, Light Intensity, more floats and flow-rate sensors.

I liked the simple inventory management system application so much, I borrowed its web interface to improve hydroMazing:

hydroMazing snapshot

What are the steps needed to use hydroMazing?

  • Connect the Raspberry Pi to your local router using an Ethernet cable.
  • Plug in the hydroMazing Controller unit’s USB to the Raspberry Pi.
  • Optionally, plug in the USB webcam.
  • Power the Raspberry Pi.
  • Use a Power Squid ( Multiple Plugs ) to attach the Remote Controlled AC Outlet Modules to their corresponding appliance assignment according to the hydroMazing Smart Garden System’s settings.

Plug-in appliances to their corresponding remote controlled AC switch units.  Most growing environments can be configured as follows:

  1. Light
  2. Intake Ventilation Fan
  3. Exhaust Ventilation Fan
  4. Humidifier / Heater / Additional Lighting
  5. Pump(s)

Also see Controlling Appliances.

How to Access the Web Interface:

  • Use a wormhole service such as Dataplicity.io
  • Or, Discover the IP address that your router has assigned to the Raspberry Pi, running hydroMazing Services.
  • Or, use a DDNS service to update the dynamic address assigned to your router and directly access the web interface

 

  • Login to the web interface using the admin credentials provided.  Example URL of web interface http//[your-device].dataplicity.io/hydroMazing/
  • Click ~ Settings → Automatic Timezone → Update
  • Click ~ Settings → Email Notifications → [ enter your email address ] → Save
  • If your growing environment is not within an Ethernet cable distance away from the router then you will need to configure the WiFi.
  • Click ~ WiFi Settings → SSID → [ enter your router’s SSID ]

Passkey → [ enter your router’s WiFi password ] → Save

 

hydroMazing chart

 

More About Electronics:

More About hydroMazing:

More About Indoor Gardening:

 

 

Configure Your Own Internet Router

Hook Up Your Raspberry Pi

Connecting all your devices to the Raspberry Pi is very easy, but you want to do it in a specific order so it can recognize all your devices when it boots up. First, connect your HDMI cable to your Raspberry Pi and your monitor, then connect your USB devices. If you’re using an Ethernet cable to connect to your router, go ahead and connect that as well.  Finally, once everything is connected, go ahead and plug in your power adapter. The Raspberry Pi does not have a power switch, so once you connect the power adapter, it’ll turn on all by itself.

Connect to Your Wi-Fi Network

Connecting to your Wi-Fi network works the same in Raspbian as it does it any modern operating system.

  • Click the network icon (it’s the one with two computers) in the top right corner.
  • Select your Wi-Fi network name, and enter your password.

That’s it, you’re now connected to Wi-Fi. This will work in both the command line and in the graphical interface, so you only need to set it once. If you have an older Pi and you’re using a Wi-Fi adapter like this, the process is the same.

You have several devices connected to your WiFi router, so how can you tell the outside where you are serving-up Raspberry Pi?

Getting Online

The following section assumes you have an updated and upgraded Raspberry Pi 3 or equivalent, and installed L.A.M.P. (Linux.Apache.MySQL.PHP.)  Excellent article for getting started and RaspberryPi.org’s installing LAMP.

You have several devices connected to your WiFi router, so how can you tell the outside where you are serving-up Raspberry Pi?

Use a service like dataplicity OR DIY:  Let’s get familiar with our router’s advanced settings in your router manufacturer’s configuration tool.  Most home networks use one of these common IP addresses for their gateway to the Internet:

place-wifi-router

You will need to login to your router’s configuration tool.  The username and password should have been assigned at the time of setup.  First, we need to reserve an IP address for our Raspberry Pi to use on a regular basis.  Typically, the router will have a DHCP (Dynamic Host Configuration Protocol) Settings section, List and Bindings, etc.  The Raspberry Pi and all other devices on your LAN should be listed here.  Hopefully, your router will have a somewhat intuitive interface that will make sense as to how to assign an IP address to a device or MAC address.  If all else fails, consult your manufacturer’s instructions.

decapi-slider-raspberry-pi-casenetwork-782707_1280-980x637

The default port for web requests is 80.  You can leave the default unless your Internet Service Provider doesn’t allow port 80.  Next step in your router’s configuration is to have the router forward all incoming requests on port 80 to the Raspberry Pi.  Typically referred to as, Port Forwarding or Port Range Forwarding.  You will want to associate the Raspberry Pi’s IP address so that it will receive all incoming requests on port 80 or whatever port you find most appropriate.  (The most secure web server is one that is not connected to the Internet 😉  The default port for SSL is port 443.  Next step in your router’s configuration is to have the router forward all incoming requests on port 443 to the Raspberry Pi.  Motion Web-Cam Streaming:  The default port for motion is port 8081.  Next step in your router’s configuration is to have the router forward all incoming requests on port 8081 to the Raspberry Pi.

You could also allow Telnet, FTP, SSH, VNC, etc but I do not recommend unless you are familiar with the security risks associated with such services.

Get Yourself A Domain Name

http://www.YOUR_CUSTOM_DOMAIN.ddns.net

Check for the DDNS ( Dynamic Domain Name Service ) Setting in your Router’s advanced configuration settings.  Most routers will support one or more of the following, http://www.dyn.comhttp://www.noip.com, many others search Google for “Dynamic DNS”.  The service will offer the ability to register a domain name to associate with the Dynamic IP address that is assigned to you by your Internet Service Provider.  Typically, your router or a software plugin that you download and install will update the Dynamic DNS service’s database when your assigned IP address changes.

Secure Socket Layer

https://letsencrypt.org/

Let’s Encrypt our connection with the Raspberry Pi.

Install

Rather than apt-get Cerbot, I download the latest version directly from its repo:

sudo git clone https://github.com/certbot/certbot /etc/letsencrypt

Easy SSL through Automation

Certbot has a fairly solid beta-quality Apache plugin, which is supported on many platforms, and automates both obtaining and installing certs:

sudo /etc/letsencrypt/certbot-auto

 

Your domain name for your hydroMazing should now be secure.

Wired or Wireless?

Electricity replaces the sun, wind, and some natural processes as the dependency for plants to grow indoors.  

Starting a Smart Indoor Garden

The first glaring problem with the typical indoor garden is that extension wires are annoying and a potential safety hazard.  On the other hand, wireless communications can lack the reliability of the wired variant.  Going further, should the system be available to the local network or should it be connected to the Internet?

Since plants do not need Internet access in order to grow then we are potentially creating an additional dependency that the plant doesn’t want. The Internet is useful for providing access to your system, but security is questionable, how much control or data should be available?  A connection to the Internet can become another dependency if the system cannot operate without communication to a cloud-based or otherwise remote server. If something can fail; we should plan for the eventual occurrence of that possibility as best as possible. If a long electrical outage were to occur it would be prudent to have a backup generator, or solar rechargeable battery storage system.  If we can have better reliability with a wired connection, then it makes sense to use a combination of wired and wireless.

Next:  Getting Wired and Wireless

Communication options such as i2c, which is great for communicating with another microcontroller or Raspberry Pi and the many wireless options: WiFi, bluetooth, etc.

  • Remote Control using a RF 315MHz / 433MHz
  • Lightweight Bluetooth ( nRF24L01 )
  • Bluetooth ( HC-05 )
  • WiFi Module ( ESP8266 / CC3000 ) etc.

More Info:

Please share with friends and follow to receive a notification when I publish a new article.

 

Why Arduino when you can Pi?

Arduino
Arduino ProMini, Uno, and Nano on expansion board.

Why Arduino?

The greatest advantage to using the Arduino family of microcontrollers for DIY electronics projects, is that they are ubiquitous.  Since they are so available, they are inexpensive and you can find open-source software to get started.

If you’ve ever had the opportunity to work with an Arduino Uno microcontroller board, then you’ve probably executed the flashing LED example.  Going further, you might attach a button, or switch, to trigger the LED or to turn it off making the project interactive.  There are many sensors that could be connected to the Arduino Uno and setup to trigger events, such as the LED flashing, using threshold values that we would need to experiment with in order to figure out what settings work best for creating the effect we want.

While the examples that come with the Arduino software and the examples included with libraries are an excellent start to a project; the Arduino family of microcontrollers is often grossly underutilized in many projects.  Sure microcontrollers are limited in how many instructions they can run; hitting the program size limit doesn’t take very long when you want to control more than a few blinking LEDs.  Even with creative variable handling and custom libraries, eventually, there is a need for another microcontroller or to move to a larger one, even a Raspberry Pi.

In my Alien Invasion Slot Machine project, I tried to push the Arduino closer to its limits.

Time Management and state and trigger flagsf0zk2etiagml1az-medium

At its most basic, a microcontroller loops through a set of instructions handling each action with the focus of The Red Eye of Sauron from Lord of the Rings.  There are a few interrupts that can be configured should an event be so important to receive the full attention of the microcontroller.  Using some form of time management creates a state machine. If x amount of time has passed since x event, then do something and so on…

“The behavior of state machines can be observed in many devices in modern society that perform a predetermined sequence of actions depending on a sequence of events with which they are presented. Simple examples are vending machines, which dispense products when the proper combination of coins is deposited, elevators, whose sequence of stops is determined by the floors requested by riders, traffic lights, which change sequence when cars are waiting, and combination locks, which require the input of combination numbers in the proper order.” https://en.wikipedia.org/wiki/Finite-state_machine

There are rare instances where: RTOS, AI, neural networks exist on microcontrollers, but that’s best left to software-oriented systems such as a Raspberry Pi.

After trying many different timer and time management libraries I felt they were either too much or not enough of what I was wanting in my timers.  A set of timers that are easy to set, keep track of their own state, and each have their own trigger flags.

Button assumptions

buttons

Interacting with an electronics device such as a microcontroller or computer system is relatively easy and typically provided as an example for developers looking to use the device in their project.  Press a button and an LED illuminates. A button or switch may seem like a simple sensor input, but it’s not.

The device’s system resources are consumed waiting and watching for a button press. When we use a button in a project we typically think of it being activated when pressed.  Then what? What should happen if the user holds the button in the active position? Will the button be counted as pressed once, or is the program going to count each second, or x amount of time, as another button press?  Does the program need to know that the button has been released?

Hardware and wiring

wiring harness

Rather than using the Arduino Uno and a protoboard or breadboard for this project, I’m using the Arduino Nano on an expansion board.  Keep it simple using common wiring colors, keep it modular so connections can be made with ease, keep your project sustainable; a part can be replaced rather than the entire system.  The DuPont wire connectors that come with prototyping starter kits makes it easy to create your own custom wiring connections. The wires are easy to solder when a more permanent connection is needed.  I make custom wiring harnesses for neater, cleaner, and more easily connectable modules.

 

Raspberry Pipi3

The latest version of the Raspberry Pi v3 uses a Linux OS and is a computer that can do so much more than an Arduino Uno, why not just use it for everything?  While it is possible to do many of the same tasks as you would do with the Arduino Uno or variant, it’s not always best.  The Arduino Uno and variant microcontrollers are best for doing the same actions, over and over again, such as reading a sensor and doing something with the value.

As I mentioned previously, you can do a lot with a Raspberry Pi, and depending on how much you are doing, it won’t take too long before you discover it has limits.  When the Pi overheats, it will either freeze or shutdown, hopefully, the processor has a heatsink.

More Info:

Please share with friends and follow to receive a notification when I publish a new article.

Why DIY when you could buy?

You value the project because you are able to customize and experience the process of its creation, both physically and mentally.

Practical Reasons:

  • Integrity and dependency on specific vendor:  Complete packages are limited in capability and scalability, also they often include unwanted strings attached, i.e. Advertisements; company owns your data for purposes of profiting by selling for marketing purposes.  Mass produced products are typically not designed for longevity. Can the equipment be repaired or is it disposable?
  • People have complex preferences and want more customizable, possibly less expensive solutions, typically with the trade-off related to labor, can be improved or perform to preferred standards
  • Interest in learning and/or educating others:  You enjoy or have an interest in the activities associated with the process of a subject.
  • Necessity:  Resources and costs vary by region.
  • What else?

Cost considerations

Many items can be purchased locally or sourced from the Worldwide market through the Internet.  I don’t know about you, but I rarely have money to spend on projects and whenever possible reusing and re-purposing junk is ideal.  Many of my projects contain parts I’ve purchased at local dollar stores and items found through eBay online vendors. Online researching, reviewing, and sourcing materials

Time

It takes time to learn how to use tools and equipment successfully, let alone, have the time to actually make the project meet your expectations.  Will you take the time to safely use the equipment necessary to complete the project?  Are you able and willing to troubleshoot problems as they arise?

Time used for the project is time that could be spent with family, friends, learning something more important, etc.

Skill and Ability

Even though it may pain me to swallow my pride, I try not reinvent the wheel.  If I don’t have direct experience performing a task, I take the time to research how others have approached similar problems.  It is best to learn from others before making a serious mistake simply because I don’t want to appear stupid. Practice makes permanent. We cannot expect to become experts on a subject overnight, it’s okay not to know how to do something, try to find someone who can help, take small simple steps towards achieving the goal.

Resources for DIY Hacking Electronics:

For electronics projects, reliably wiring the hardware and designing the software to operate using an Arduino variant or Raspberry Pi, is a challenge.  Hacking Electronics – Simon Monk ( link to Amazon ).  Regardless of your experience level, this book is an excellent resource, what tools are needed, when and how to solder, and many basic fundamentals of working with modern electronics.  The second edition, includes Raspberry Pi.

More Info:

Please share with friends and follow to receive a notification when I publish a new article.

Arduino FastLED Library

RGB Strip

The FastLED library is an impressive piece of work:

https://github.com/FastLED/FastLED/wiki/Basic-usage

After you download and install the library give it a try:

Using an Arduino Uno to calibrate an RGB LED strip.

The purpose of running this example is to determine what settings are needed to use the FastLED library.  For this example I’m using an Arduino Uno. The Uno has a ground pin next to pin 13, so for convenience, I’m using pin 13 as a low-current Vcc for the RGB LED lights strip:

pinMode(13, OUTPUT);
digitalWrite(13, HIGH);

// The data pin is the pin we are using to connect to the Arduino.
// Data pin that led data will be written out over
#define DATA_PIN 12

// How many individual LED modules are on the strip?
#define NUM_LEDS 10

// When using an SPI based chipset, the there should be four wires
// Clock pin only needed for SPI based chipsets when not using hardware SPI
//#define CLOCK_PIN 8

Important configuration setting is to specify the model of LED strips being used.  May require some try-and-error.

      // Uncomment one of the following lines for your leds arrangement.

     // FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
      FastLED.addLeds<WS2812, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
      // FastLED.setBrightness(CRGB(255,255,255));
      // FastLED.addLeds<GW6205, DATA_PIN, RGB>(leds, NUM_LEDS);

A nice variety of color effects is included with the library.  After trying out the RGBCalibration source code example, make the changes need to Demo Reel and give it a go:  https://github.com/FastLED/FastLED/blob/master/examples/DemoReel100/DemoReel100.ino

Copy the settings for the LED strip to the DemoReel example

Upload and if all goes well, you should see a basic visual effects show.

Lightshow

More

Please share with friends and follow to receive a notification when I publish a new article.

 

IMG_20190605_094809140
Existential Crisis

Making a Lightshow with Arduino

They are in games, decorations, shadow boxes, sign borders, torches, spotlights, and so on…

 

 

 

 

This slideshow requires JavaScript.

Making a Lightshow

Using an Arduino Nano on an expansion board with a push-button to change the color palette mode of the RGB LED strip.  A microphone module is used to detect sound and alter the speed of flashing lights.

Arduino

Why Arduino?

The greatest advantage to using the Arduino family of microcontrollers for these types of projects, is that they are ubiquitous.  Since they are so available, they are inexpensive and you can find open-source software to get started. If you’ve ever had the opportunity to work with an Arduino Uno microcontroller board, then you’ve probably executed the flashing LED example.  Going further, you might attach a button, or switch, to trigger the LED or to turn it off making the project interactive.

There are many sensors that could be connected to the Arduino Uno and setup to trigger events, such as the LED flashing, using threshold values that we would need to experiment with in order to figure out what settings work best for creating the effect we want.

While the examples that come with the Arduino software and the examples included with libraries are an excellent start to a project; the Arduino family of microcontrollers is often grossly underutilized in many projects.  Sure microcontrollers are limited in how many instructions it can run and hitting the program size limit doesn’t take very long when you want to control more than a few blinking LEDs.

Even with creative variable handling and custom libraries, eventually, there is a need for another microcontroller or to move to a larger one.  In my hydroMazing Smart Garden System and in my Alien Invasion Slot Machine projects, I push the Arduino closer to its limits.

Time Management and state and trigger flags

At its most basic, a microcontroller loops through a set of instructions handling each action with the focus of The Red Eye of Sauron from Lord of the Rings.  There are a few interrupts that can be configured should an event be so important to receive the full attention of the microcontroller.  Using some form of time management creates a state machine. If x amount of time has passed since x event, then do something and so on…

“The behavior of state machines can be observed in many devices in modern society that perform a predetermined sequence of actions depending on a sequence of events with which they are presented. Simple examples are vending machines, which dispense products when the proper combination of coins is deposited, elevators, whose sequence of stops is determined by the floors requested by riders, traffic lights, which change sequence when cars are waiting, and combination locks, which require the input of combination numbers in the proper order.” https://en.wikipedia.org/wiki/Finite-state_machine

There are rare instances where: RTOS, AI, neural networks exist on microcontrollers, but that’s best left to software-oriented systems such as a Raspberry Pi.

After trying many different timer and time management libraries I felt they were either too much or not enough of what I was wanting in my timers.  A set of timers that are easy to set, keep track of their own state, and each have their own trigger flags.

Button assumptions

buttons

Interacting with an electronics device such as a microcontroller or computer system is relatively easy and typically provided as an example for developers looking to use the device in their project.  Press a button and an LED illuminates. A button or switch may seem like a simple sensor input, but it’s not.

The device’s system resources are consumed waiting and watching for a button press. When we use a button in a project we typically think of it being activated when pressed.  Then what? What should happen if the user holds the button in the active position? Will the button be counted as pressed once, or is the program going to count each second, or x amount of time, as another button press?  Does the program need to know that the button has been released?

Hardware

I’m going to be adding on a lot of peripheral devices and moving away from basic prototyping.  Rather than using the Arduino Uno and a protoboard or breadboard for this project, I’m using the Arduino Nano on an expansion board.  I’ve created several color palettes by porting the sample code from the FastLED library examples to my base code templates.  with a push-button input to change the color palette mode of the RGB LED strip.

wiring harness

Wiring

Keep it simple using common wiring colors, keep it modular so connections can be made with ease, keep your project sustainable; a part can be replaced rather than the entire system.  The DuPont wire connectors that come with prototyping starter kits makes it easy to create your own custom wiring connections. The wires are easy to solder when a more permanent connection is needed.  I make custom wiring harnesses for neater, cleaner, and more easily connectable modules.

 

Lighting Effects

There many RGB LED options, so I will be focusing on the WS2811/WS2812 modules.  Single RGB LEDs to strings of RGB LEDs in various configurations. Most of the RGB options wilRGB Stripl have three wires for connecting to the microcontroller board and require 5vdc or 12vdc.  Unless you are designing a new printed circuit board, use DC/DC conversion modules to convert your power to the needs of your project.  You might need to step-up voltage from 3v to 5v, or maybe step-down 12v to 5v?

*** The more lights added, the more power needed. ***

The Arduino Uno, and variants, should only be used for directly powering peripheral modules and not devices.  Consider the maximum current consumption when determining what is a device and what is a module.  A string of lights is more of a device as opposed to a panel indicator light, motor controller boards are modules, not the motors they drive, MOSFET boards, not the valves or solenoids that they control.  See Arduino FastLED Library.

 

 

 

 

 

Common Options for Power

  • USB Powered Devices
  • AC/DC wall-wart Power Supplies
  • Rechargeable Batteries
  • Solar Panels
  • power

Parts:

  • Arduino Nano
  • Expansion Board
  • USB to mini USB cord
  • AC/DC Outlet Power Adapter
  • Project Box
  • (1-4) strips of 10 RGB 12mm LEDs.
  • (1) push-buttons
  • microphone

bad connection

Steps:

Insert Arduino Nano into the Expansion Board by carefully pressing the Nano pins into the expansion boards headers.  Note the picture where only half of the pins are correctly inserted.  Plan to provide power using USB to mini USB cord.  Optionally, AC/DC Outlet Power Adapter.

Prepare the following wiring connections to the expansion board by soldering and protecting with heat-shrink:

  • (1-4) strips of 10 RGB 12mm LEDs.
  • (1) push-button
  • microphone

Programming considerations:

  • brightness of lights
  • color palette
  • speed of flashing lights
  • what triggers change?

Connect the push-button to the expansion board.

Connect strip(s) of 10 RGB 12mm LEDs to the expansion board and upload test code.

Optionally, connect the potentiometer to the expansion board and upload test code.

mic and pir

Making projects more interactive

Every sensor gives us a data-point to work with, providing an input so that our program can make a decision based on its current environment or what happens when conditions are met.  Going further with the project, I’ve added a microphone to detect sound, and at a later time, I’ll add a PIR sensor to detect motion.

 

 

Connect the microphone to the expansion board and upload test code.

Lightshow Inside

Complete the project with an enclosure.

  • Drill 7/16” – 1/2” holes into the project box:
  • HOLE 1: side ~ USB to mini USB cord ~ Optionally, AC/DC Outlet Power Adapter
  • HOLE 2:  cover ~ push-button
  • HOLE 3:  side ~ 1-4 x strips of 10 RGB 12mm LEDs

Lightshow

More:

Keep Fingers Out of your Pi

In my previous article , I explain how to setup the Raspberry Pi to be a web server.   I also demonstrate searching log files for “footprints” from the IP requests that have been made to your web server.  Now, I would like to discuss protecting your web server from becoming a victim to a potentially malicious attack.

Keep your Pi updated!

sudo rpi-update

The command will automatically update the Raspberry Pi’s firmware and then ask for a reboot.  If your Pi is already up-to-date, then you can continue with:

sudo apt-get update
sudo apt-get upgrade

Now, you’ve got the latest and greatest firmware and software!!

2016-11-04-092217_1920x1080_scrot

Pi Passwords

Ideally, we would disable the default pi account,  at the very least, set the default password for your pi account.  Another major in-security is that most users have SSH (Secure Socket sHell) and VNC (Virtual Networking Computer) enabled so that they can remote into their machines.  I don’t recommend allowing access outside of your network when running a publicly exposed web server.

Apache Web Server

If you are serving web content world-wide then you’ll eventually want to adopt some sort of blacklist, or exclusion list, where you can keep specific IP addresses from accessing your server.  However, if you want to tighten-down your security and only allow a select few access then you’ll need to make some changes.

cd /etc/apache2
sudo cp apache2.conf apache2.conf.bak
sudo vi apache2.conf OR sudo nano apache2.conf

Travel down the file until you reach this section that allows everyone access to your web server from the outside:

<Directory /var/www/>
 Options Indexes FollowSymLinks
 AllowOverride None
 Require all granted
</Directory>

The AllowOverride directive is set to None meaning we will not be using an .htaccess file to override these settings.  The next directive, Require is set to all granted, meaning allow anyone access.

UPDATE:  I have found a significant number of bot requests in my log files, snooping for those of Us using phpmyadmin, be sure to limit access:

<Directory /usr/share/phpmyadmin/>
Order Deny, Allow
Deny from All
# localhost
Allow from 127.0.0.1
# Local-Area Network
Allow from 192.168.x.x
</Directory>

Next, we can add a directory that we want to protect:

<Directory /var/www/html/hydroMazing/>
 Options Indexes FollowSymLinks
 AllowOverride All
</Directory>

The AllowOverride directive is set to All meaning we will be using an .htaccess file to override these settings.  We will provide the Require directive in our .htaccess file inside the directory we specified, in this case, “/var/www/html/hydroMazing/”   One last setting of importance before we save:

# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives. See also the AllowOverride
# directive.
#
AccessFileName .htaccess

You could change the name of the .htaccess file here to something harder to guess.  Keep the dot at the beginning because it means hidden file.   Use your imagination 😉  Now you can use an .htaccess file as your whitelist, or inclusion list:

To create a .htaccess ( or whatever you’ve named it ) file:

cd /var/www/html/mydirectory/

sudo vi .htaccess OR sudo nano .htaccess
# Allow access to localhost 
Require ip 127.0.0.1

# Allow access to my cell phone
Require ip 98.97.34.23

Second entry is an example, change it to your IP address, or the IP address that your web server logged.  See my previous article for instructions on checking your log files.  Save and close the file.  You can add additional access as desired.

 

Build a Wallimg_20160814_195916221

Install the open-source firewall builder

Pop open a terminal from your Raspberry Pi’s desktop and type the following:

sudo apt-get install fwbuilder

After the installation has completed, you will have a new option under the Menu/Internet option from your desktop for the firewall builder GUI.

Add a new firewall and name it the same as your server.

 2016-11-04-090801_1920x1080_scrot

Select the “web server” template to load default rules.

Note that the default rules restrict your server from accessing the outside Internet.  In order to allow access, you’ll need to add a rule.  The easiest way to add a rule is to copy an existing rule that is similar to your needs.

2016-11-04-090900_1920x1080_scrot

Compile and Install

We can build our firewall through this interface, but we won’t be able to install it because we won’t have sufficient permissions to write to the file system.  Enter the following at a terminal window’s command line assuming you named your server the same as your DDNS name:

sudo mkdir /etc/fw
sudo touch /etc/fw/servername.ddns.net.fw
sudo chmod 777 /etc/fw/servername.ddns.net.fw

Now, you should be able to use the firewall builder program to compile and install the firewall.   You can either restart the apache web server or simply reboot.

Anything incorrect, missing, or not working?  Please let me know.

Power to the People!

We believe you shouldn’t need expensive gadgets and technical expertise to be a successful gardener. We are committed to a greener planet!

A handy IndoorGardeningChecklist – print yourself a copy!


Image Credits: Power to the People, Patrick Nygren 2014.
Creative Commons Commercial Use License.