{"id":635,"date":"2017-05-20T19:56:18","date_gmt":"2017-05-20T11:56:18","guid":{"rendered":"https:\/\/www.techcoil.com\/blog\/?p=635"},"modified":"2018-09-03T21:02:31","modified_gmt":"2018-09-03T13:02:31","slug":"how-i-setup-a-cctv-camera-with-raspberry-pi-zero-w-and-motioneyeos-image-for-home-surveillance","status":"publish","type":"post","link":"https:\/\/www.techcoil.com\/blog\/how-i-setup-a-cctv-camera-with-raspberry-pi-zero-w-and-motioneyeos-image-for-home-surveillance\/","title":{"rendered":"How I setup a CCTV camera with Raspberry Pi Zero W and motionEyeOS image for home surveillance"},"content":{"rendered":"<p>When the <a href=\"https:\/\/www.amazon.com\/gp\/product\/B06XFZC3BX\/ref=as_li_tl?ie=UTF8&tag=clivsperswebs-20&camp=1789&creative=9325&linkCode=as2&creativeASIN=B06XFZC3BX&linkId=141ed8cff795cb56ba1e6bc4a7e2bc1e\" target=\"_blank\">Raspberry Pi Zero W<\/a> was launched, I didn't think twice before ordering one. Compared to the Raspberry Pi Zero, the Raspberry Pi Zero W comes with WiFi. This meant that I can use my new Raspberry Pi Zero W to replace my <a href=\"https:\/\/www.techcoil.com\/blog\/how-i-built-my-home-raspberry-pi-3-cctv-using-a-motion-eye-os-image-from-home-surveillance\/\" target=\"_blank\">Raspberry Pi 3 CCTV camera<\/a> for home surveillance and use the more powerful Raspberry Pi 3 for other projects.<\/p>\n<p>This post documents how I setup my Raspberry Pi Zero W as a CCTV camera using the <a href=\"https:\/\/github.com\/ccrisan\/motioneyeos\" target=\"_blank\">motionEyeOS<\/a> image.<\/p>\n<h2>Hardware used for this CCTV camera setup<\/h2>\n<p>I utilized the following hardware component for this CCTV camera setup:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.amazon.com\/gp\/product\/B06XD18H6K\/ref=as_li_tl?ie=UTF8&tag=clivsperswebs-20&camp=1789&creative=9325&linkCode=as2&creativeASIN=B06XD18H6K&linkId=dfbc249fe8b4825d9c8d9e6dbb04e2bb\" target=\"_blank\"> Raspberry Pi Zero W (Wireless) & Official Case <\/a><\/li>\n<li><a href=\"https:\/\/www.amazon.com\/gp\/product\/B00E1GGE40\/ref=as_li_tl?ie=UTF8&tag=clivsperswebs-20&camp=1789&creative=9325&linkCode=as2&creativeASIN=B00E1GGE40&linkId=f0914fa9c06442f5feec0d0c2b96d3c5\" target=\"_blank\">Raspberry Pi 5MP Camera Board Module<\/a><\/li>\n<li><a href=\"https:\/\/www.amazon.com\/gp\/product\/B010Q57S62\/ref=as_li_tl?ie=UTF8&tag=clivsperswebs-20&camp=1789&creative=9325&linkCode=as2&creativeASIN=B010Q57S62&linkId=59d887701de92d95b419d7396cea24f9\" target=\"_blank\">SanDisk Ultra 128GB microSDXC UHS-I Card with Adapter, Black, Standard Packaging <\/a><\/li>\n<li><a title=\"Amazon page on Belkin 4-Foot MIXIT Micro USB cable\" href=\"http:\/\/www.amazon.com\/gp\/product\/B00E65OM3Q\/ref=as_li_qf_sp_asin_il_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=B00E65OM3Q&linkCode=as2&tag=clivsperswebs-20&linkId=6U5CEOWOEZBQANTR\" target=\"_blank\" data-amzn-asin=\"B00E65OM3Q\">Belkin micro USB cable<\/a> <\/li>\n<li>Unused <a href=\"https:\/\/www.amazon.com\/s\/ref=as_li_ss_tl?url=search-alias=aps&field-keywords=USB+charger&linkCode=ll2&tag=clivsperswebs-20&linkId=3f0cc3128101afcfe7ccdc4d9c856568\" rel=\"noopener\" target=\"_blank\">USB charger<\/a><\/li>\n<\/ul>\n<p>Note that I had utilized an earlier version of the Raspberry Pi Camera module. If you do not have a Raspberry Pi Camera module, you may want to get the <a href=\"https:\/\/www.amazon.com\/gp\/product\/B01ER2SKFS\/ref=as_li_tl?ie=UTF8&tag=clivsperswebs-20&camp=1789&creative=9325&linkCode=as2&creativeASIN=B01ER2SKFS&linkId=b9cb4fca0f1ec7f01f9879067686d31e\" target=\"_blank\">Raspberry Pi Camera module V2<\/a> instead. <\/p>\n<h2>Preparing the motionEyeOS image on my microSD card<\/h2>\n<p>The first task that I took to setup my Raspberry Pi Zero W as a CCTV camera is to prepare the motionEyeOS image on my microSD card.<\/p>\n<h3>Choosing the right version of motionEyeOS for my Raspberry Pi Zero W CCTV camera<\/h3>\n<p>The <a href=\"https:\/\/github.com\/ccrisan\/motioneyeos\/releases\" rel=\"noopener\" target=\"_blank\">latest release of motionEyeOS can be found here<\/a>.<\/p>\n<p>As of this writing, there are <a href=\"https:\/\/github.com\/ccrisan\/motioneyeos\/wiki\/Supported-Devices\" target=\"_blank\">three versions of motionEyeOS images<\/a> available for setting up CCTV cameras on Raspberry Pi boards: <\/p>\n<ul>\n<li>MotionEyeOS image for Raspberry Pi (A, B, A+, B+, Compute Module, Zero and Zero W models)<\/li>\n<li>MotionEyeOS image for Raspberry Pi 2<\/li>\n<li>MotionEyeOS image for Raspberry Pi 3<\/li>\n<\/ul>\n<p>Since I was setting up a CCTV camera with a Raspberry Pi Zero W board, I downloaded the first image option, motioneyeos-raspberrypi-20170329.img.gz, onto my MacBook Pro. <strong>You should always <a href=\"https:\/\/github.com\/ccrisan\/motioneyeos\/wiki\/Supported-Devices#user-content-raspberry-pi-a-b-a-b-compute-module-zero-and-zero-w-models\" rel=\"noopener\" target=\"_blank\">download the latest release of motionEyeOS for your Raspberry Pi Zero W<\/a><\/strong>. <\/p>\n<h3>Installing the motionEyeOS image on my microSD card<\/h3>\n<p>Although I used to <a href=\"https:\/\/www.techcoil.com\/blog\/how-to-prepare-the-operating-system-to-run-your-raspberry-pi-with-your-windows-machine\/\" target=\"_blank\">install Raspberry Pi operating system with my Windows machine<\/a>, I chose to <a href=\"https:\/\/www.techcoil.com\/blog\/an-easy-way-to-install-raspberry-pi-operating-system-on-a-mac\/\" target=\"_blank\">install the operating system image with my Mac<\/a> this time round.<\/p>\n<p>To install the motionEyeOS image on my microSD card, I first extracted <code>.img<\/code> file from motioneyeos-raspberrypi-20170329.img.gz.<\/p>\n<p>I then inserted the microSD card via its adapter into my MacBook Pro.<\/p>\n<p>Finally, I selected the <code>.img<\/code> file that I had extracted earlier and click on the \"Flash!\" button on Etcher. Once Etcher had completed installing the motionEyeOS image on my microSD card, I then proceeded to prepare the WiFi configurations for my Raspberry Pi Zero W CCTV camera to connect to my home WiFi network.<\/p>\n<h3>Getting the Raspberry Pi Zero W CCTV camera connect to my home WiFi on first boot<\/h3>\n<p>The easiest way to configure my Raspberry Pi Zero W CCTV camera is to get it to connect to my home WiFi so that I can communicate with motionEyeOS's web server through a web browser running on my MacBook Pro. <\/p>\n<p>To get my Raspberry Pi Zero W CCTV camera to connect to my home WiFi on first boot, I first used nano to create the <code>wpa_supplicant.conf<\/code> file and saved it on my Desktop:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nupdate_config=1\r\nctrl_interface=\/var\/run\/wpa_supplicant\r\n\r\nnetwork={\r\n        scan_ssid=1\r\n        ssid=&quot;my-home-wifi-ssid&quot;\r\n        psk=&quot;my-home-wifi-password&quot; \r\n}\r\n<\/pre>\n<p>After saving the file, I dragged <code>wpa_supplicant.conf<\/code> into the microSD card:<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/motioneye-os-image-with-wpa_supplicant.conf-on-microSD-card.png\" alt=\"motionEyeOS image with wpa_supplicant.conf on microSD card\"\/><\/p>\n<h2>Connecting the Raspberry Pi Camera Module to Raspberry Pi Zero W board and the Official Case<\/h2>\n<p>After preparing the microSD card, I inserted the microSD card into the microSD card slot on my Raspberry Pi Zero W board. With that, I could then <a href=\"https:\/\/www.techcoil.com\/blog\/connect-raspberry-pi-camera-module-raspberry-pi-zero-w-official-case\/\" target=\"_blank\">connect the Raspberry Pi Camera Module to the Raspberry Pi Zero W board and the Raspberry Pi Zero Official Case<\/a>. After assembling the parts, my Raspberry Pi Zero W CCTV camera looks like this:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/raspberry-pi-zero-official-case-with-camera-module-and-zero-w-board.jpg\" alt=\"Raspberry Pi Zero Official Case with Camera Module and Zero W board\"\/><\/p>\n<h2>Booting into motionEyeOS on my Raspberry Pi Zero W CCTV camera<\/h2>\n<p>Once I had assembled the parts for Raspberry Pi Zero W CCTV camera, the next step that I did was to connect my <a title=\"Amazon page on Belkin 4-Foot MIXIT Micro USB cable\" href=\"http:\/\/www.amazon.com\/gp\/product\/B00E65OM3Q\/ref=as_li_qf_sp_asin_il_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=B00E65OM3Q&linkCode=as2&tag=clivsperswebs-20&linkId=6U5CEOWOEZBQANTR\" target=\"_blank\" data-amzn-asin=\"B00E65OM3Q\">Belkin micro USB cable<\/a> to the power port on my Raspberry Pi Zero W CCTV camera. The other end of my <a title=\"Amazon page on Belkin 4-Foot MIXIT Micro USB cable\" href=\"http:\/\/www.amazon.com\/gp\/product\/B00E65OM3Q\/ref=as_li_qf_sp_asin_il_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=B00E65OM3Q&linkCode=as2&tag=clivsperswebs-20&linkId=6U5CEOWOEZBQANTR\" target=\"_blank\" data-amzn-asin=\"B00E65OM3Q\">Belkin micro USB cable<\/a> was connected to my USB wall plug charger to draw power into my Raspberry Pi Zero W CCTV camera.<\/p>\n<p>Since I did not have a micro HDMI cable with me, I logged into the status page of my <a href=\"https:\/\/www.amazon.com\/gp\/product\/B00NCEYGHE\/ref=as_li_tl?ie=UTF8&tag=clivsperswebs-20&camp=1789&creative=9325&linkCode=as2&creativeASIN=B00NCEYGHE&linkId=5fab2f69f61013214622b6aec7d247eb\" target=\"_blank\">DLink router<\/a> to check whether my Raspberry Pi Zero W CCTV camera had completed the first boot operations. <\/p>\n<p>When my Raspberry Pi Zero W CCTV camera had completed the first boot operations, it would have requested for a private IP address via DHCP. When the private IP address requisition was successful, my router's status page was updated with an entry in the table under the \"LAN COMPUTERS\" section. <\/p>\n<p>To get the private IP address of my Raspberry Pi Zero W CCTV camera, I looked for the row with a name of the form \"meye-xxxxxxxx\". Indeed, there was such an entry and the corresponding IP address that my Raspberry Pi Zero W CCTV camera had been given was <strong>192.168.0.116<\/strong>. <\/p>\n<h2>Accessing the camera video stream on my Raspberry Pi Zero W CCTV camera with my browser from within my home network <\/h2>\n<p>To access the camera video stream on my Raspberry Pi Zero W CCTV camera, I entered <strong>192.168.0.116<\/strong> into the location bar of my web browser on my MacBook Pro.<\/p>\n<p>With that, I got the following screen:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/first-access-to-raspberry-pi-zero-w-cctv-via-chrome.jpg\" alt=\"First access to Raspberry Pi Zero W CCTV camera via Chrome\"\/><\/p>\n<h2>Making sure that my Raspberry Pi Zero W CCTV camera can only be accessed through my user account<\/h2>\n<p>By default, motionEyeOS allows anybody with a browser to watch the camera video stream of my Raspberry Pi Zero W CCTV camera without any restriction. I am definitely not comfortable with this default setting. Hence, the first configuration that I made to my Raspberry Pi Zero W CCTV camera was to set some passwords to restrict access to the camera stream.<\/p>\n<p>To apply access control to the motionEyeOS running on my Raspberry Pi Zero W CCTV camera, I would need to login as the admin user. <\/p>\n<p>To login with the admin user, I clicked on the person icon at the top left corner of the screen and was shown the following screen:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/motion-eye-os-login-prompt-on-raspberry-pi-zero-w-cctv.jpg\" alt=\"motionEyeOS login prompt on Raspberry Pi Zero W CCTV\"\/><\/p>\n<p>I then entered <strong>admin<\/strong> as the username, left the password field blank and clicked on <strong>Login<\/strong>.<\/p>\n<p>With that, the camera video stream appeared on the browser window again. Next, I clicked on the hamburger icon on the top left corner of the screen to and was shown the configuration panel:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/motion-eye-os-v20170329-with-configuration-panel-shown.jpg\" alt=\"motionEyeOS v20170329 with configuration panel shown\"\/><\/p>\n<h3>Setting a password for the admin user<\/h3>\n<p>In motionEyeOS, only the admin user is allowed to configure motionEyeOS and the username of the admin user cannot be changed.<\/p>\n<p>To set a password for the admin user, I entered a password in the \"Admin Username\" text field.<\/p>\n<h3>Creating the surveillance user<\/h3>\n<p>The surveillance user is only granted view access to the video stream from my Raspberry Pi Zero W CCTV camera. Configuring a username and password for the surveillance user would ensure that the video stream from my Raspberry Pi Zero W CCTV camera only displays after either the surveillance user or admin user logs in successfully.<\/p>\n<p>To create a surveillance user, I entered a username in the \"Surveillance Username\" field and a password in the \"Surveillance Password\" text field.<\/p>\n<h3>Saving the access control configurations<\/h3>\n<p>Once I was satisfied with the surveillance username and passwords that I had chosen for both the admin and surveillance users, I then clicked on the \"Apply\" button that appeared at the top. Doing so resulted in a prompt to reboot motionEyeOS:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/motion-eye-os-v20170329-with-system-reboot-prompt-after-setting-access-control-configurations.jpg\" alt=\"motionEyeOS v20170329 with system reboot prompt after setting access control configurations\"\/><\/p>\n<p>I clicked \"Yes\" to make motionEyeOS reboot itself.<\/p>\n<p>After my Raspberry Pi Zero W CCTV camera started up again, I was shown the login prompt.<\/p>\n<p>I keyed in my admin user credentials to continue on with configuring my Raspberry Pi Zero W CCTV camera.<\/p>\n<h2>Turning on Advanced Settings<\/h2>\n<p>After setting the access control to my Raspberry Pi Zero W CCTV camera, I proceeded to turn on \"Advanced Settings\" so that I could configure motionEyeOS further.<\/p>\n<p>To turn on \"Advanced Settings\", I clicked on the toggle button next to \"Advanced Settings\" under the \"General Settings\" tab:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/motion-eye-os-v20170329-with-after-turning-on-advanced-settings.jpg\" alt=\"motionEyeOS v20170329 with after turning on advanced settings\"\/><\/p>\n<p>I then clicked the \"Apply\" button at the top.<\/p>\n<h2>Changing the default timezone<\/h2>\n<p>The default timezone for motionEyeOS was set to UTC, which was not the timezone for the region where I resided in. This resulted in inaccurate timestamp on my camera video. Such inaccurate time display would create inconvenience when I wanted to verify whether the deliveryman from the postal service had really attempted to come to my house at the time that they had claimed in their failed delivery sms message.<\/p>\n<p>To avoid having to calculate the timestamp for my region from the UTC timestamp, an easier way would be to change the default timezone on my Raspberry Pi Zero W CCTV camera. To change the default timezone to the one that my region follows, I selected \"Asia\/Singapore\" from the Time Zone dropbox and clicked the \"Apply\" button at the top of the screen to save the changes. I clicked \"Yes\" when motionEyeOS prompted to reboot itself.<\/p>\n<p>After my Raspberry Pi Zero W CCTV camera started up again, I keyed in my admin user credentials to continue on with the other configurations.<\/p>\n<h2>Turning off the camera LED indicator<\/h2>\n<p>Since the Raspberry Pi Zero Official Case is opaque, it doesn't make much sense to turn on the camera LED indicator. Furthermore, turning off the camera LED indicator can also reduce the power consumption of my Raspberry Pi Zero W CCTV camera. <\/p>\n<p>To turn off the camera LED indicator on my Raspberry Pi Zero W CCTV camera, I clicked on the \"Expert Settings\" tab and clicked on the toggle button beside \"Enable CSI Camera Led\":<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/motion-eye-os-v20170329-with-csi-camera-led-disabled.jpg\" alt=\"motionEyeOS v20170329 with CSI Camera Led disabled\"\/><\/p>\n<p>I then clicked on the \"Apply\" button at the top and reboot my motionEyeOS.<\/p>\n<p>After my Raspberry Pi Zero W CCTV camera started up again, I keyed in my admin user credentials to continue on with the other configurations.<\/p>\n<h2>Changing video resolution<\/h2>\n<p>The default resolution setting of 320 X 200 for the Raspberry Pi Zero W CCTV camera made the videos look too blurry. With a 128 GB microSD card, I could afford a higher resolution for the videos that my Raspberry Pi Zero W CCTV camera is going to capture. <\/p>\n<p>To change the video resolution, I clicked on the \"Video Device\" tab, select the \"1024 X 768\" option from the drop down box besides \"Video Resolution\" and clicked \"Apply\" at the top:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/motion-eye-os-v20170329-video-resolutions-changed-to1024x768.jpg\" alt=\"motionEyeOS v20170329 video resolutions changed to 1024x768\"\/><\/p>\n<p>Once the setting is applied, I got a better view of the area that my Raspberry Pi Zero W CCTV camera was pointing at.<\/p>\n<h2>Limiting the preservation of still images and movies<\/h2>\n<p>By default, motionEyeOS keeps images and movies for as long as it can. In the event where the storage space on the microSD card got maxed out, it will stop recording movies. This is not an ideal behaviour for my use case. To ensure that there is always storage space for new videos, there is a need to limit the preservation of still images and movies.<\/p>\n<p>To configure the preservation period of pictures and movies, I clicked on the hamburger icon to bring out the configuration panel. Inside the configuration panel, I clicked on the \"Still Images\" and \"Movies\" tabs to expand both sections. I then chose the \"For One Month\" option for both the \"Preserve Pictures\" and \"Preserve Movies\" drop down boxes. <\/p>\n<p>Changes to both drop down boxes caused the following prompt to appear:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/motion-eye-os-v20170329-warning-prompt-after-changing-picture-preservation-settings.jpg\" alt=\"motionEyeOS v20170329 warning prompt after changing picture preservation settings\"\/><\/p>\n<p>I clicked the \"Ok\" button on both prompts and got the following configuration state:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/motion-eye-os-v20170329-with-configurations-to-preserve-pictures-and-movies-for-one-month.jpg\" alt=\"motionEyeOS v20170329 with configurations to preserve pictures and movies for one month\"\/><\/p>\n<p>Once I was done with that, I clicked on the \"Apply\" button at the top to persist the configurations and rebooted my Raspberry Pi Zero W CCTV camera.<\/p>\n<p>With that, I was satisfied with the configurations that I wanted for my Raspberry Pi Zero W CCTV camera.<\/p>\n<h2>Making my Raspberry Pi Zero W CCTV camera accessible from outside my home network through HTTPS<\/h2>\n<p>Without HTTPS, it would be insecure to access my Raspberry Pi Zero W CCTV camera from outside my home network. Protecting the HTTP traffic between a web browser and my Raspberry Pi Zero W CCTV camera would require a <a href=\"\/blog\/the-reverse-proxy-server\" target=\"_blank\">reverse proxy server<\/a>, a domain name and a SSL certificate. <\/p>\n<p>Through my experience in <a href=\"https:\/\/www.techcoil.com\/blog\/setting-up-a-lemp-web-server-on-raspberry-pi-3-with-an-ubuntu-server-15-10-3-image-to-host-a-wordpress-website\/\" target=\"_blank\">setting up a LEMP web server on Raspberry Pi 3<\/a> and <a href=\"https:\/\/www.techcoil.com\/blog\/setting-up-a-free-ca-signed-ssl-certificate-from-lets-encrypt-for-my-lemp-server-on-my-raspberry-pi-3-with-an-ubuntu-server-15-10-3-image-to-secure-my-wordpress-site\/\" target=\"_blank\">setting up a free CA signed SSL certificate to secure a WordPress site hosted on it<\/a>, I had the hardware and software resources to secure access to my Raspberry Pi Zero W CCTV camera with HTTPS.<\/p>\n<h3 id=\"create-subdomain-at-digitalocean\">Creating a sub domain from a domain that I already owned and point that sub domain to the public IP address of my home router<\/h3>\n<p>Since I own a couple of domain names, I could create a sub domain from one of the domain names. And since I am leveraging on DigitalOcean name servers to translate my domain names into IP addresses, I could create a sub domain via DigitalOcean's control panel. <\/p>\n<p>To create a sub domain via DigitalOcean's control panel, I logged into my <a href=\"https:\/\/m.do.co\/c\/68b7d9b94341\" target=\"_blank\">Digital Ocean<\/a> account and go to the \"Networking\" page. I then proceeded to the \"Domain\" tab to select a domain which I wanted to create a sub domain from. <\/p>\n<p>At the \"Create new record\" page, I entered the sub domain that I wanted for my Raspberry Pi Zero W CCTV camera and the public IP address of my home router:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/digital-ocean-page-to-create-a-new-type-a-dns-record-for-cctv-camera.gif\" alt=\"Digital Ocean page to create a new Type A DNS record for CCTV camera\" \/><\/p>\n<p>After clicking on the \"Create Record\" button, I was able to get the IP address of my home router by sending a ping to <code>cctv.adomainname.com<\/code>.<\/p>\n<p>And being able to reach my home router will meant that I was able to reach the <a href=\"https:\/\/www.techcoil.com\/blog\/setting-up-a-lemp-web-server-on-raspberry-pi-3-with-an-ubuntu-server-15-10-3-image-to-host-a-wordpress-website\/\" target=\"_blank\">LEMP server running on my Raspberry Pi 3<\/a>.<\/p>\n<h3>Configuring nginx to facilitate the Let's Encrypt client in acquiring the SSL certificate for my sub domain<\/h3>\n<p>Once I was sure that the nginx server running on my Raspberry Pi 3 could receive HTTP requests directed at my sub domain, I proceeded on with creating the nginx configurations to facilitate the Let's Encrypt client in acquiring the SSL certificate for my sub domain.<\/p>\n<p>To do so, I connected to my Raspberry Pi 3 LEMP server via SSH:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nssh root@192.168.0.123\r\n<\/pre>\n<p>Once I got into my Raspberry Pi 3 LEMP server, I used nano to create a configuration file at <code>\/etc\/nginx\/sites-enabled\/cctv.adomainname.com.conf<\/code>:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo nano \/etc\/nginx\/sites-enabled\/cctv.adomainname.com.conf\r\n<\/pre>\n<p>Once inside my nano editor, I created the following nginx configuration:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nserver {\r\n\tlisten 80;\r\n\tserver_name  cctv.adomainname.com;\r\n\r\n\troot \/var\/www\/cctv.adomainname.com;\r\n\r\n\tlocation ~ \/.well-known {\r\n\t\tallow all;\r\n\t}\r\n}<\/pre>\n<p>After creating the nginx configurations, I saved the file and restarted my nginx server:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo systemctl restart nginx.service\r\n<\/pre>\n<p>I also created the directory <code>\/www\/var\/cctv.adomainname.com<\/code> for the Let's Encrypt client to use in the process of acquiring the SSL certificate for my sub domain:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo mkdir \/www\/var\/cctv.adomainname.com\r\nsudo chown www-data:www-data \/www\/var\/cctv.adomainname.com\r\n<\/pre>\n<h3>Running Let's Encrypt client to get a SSL certificate artefacts for the sub domain to my Raspberry Pi Zero W CCTV camera<\/h3>\n<p>Once I had the configurations necessary for the Let's Encrypt client to acquire the SSL certificate artefacts for my sub domain, I ran the following command to get the Let's Encrypt client running:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\/opt\/letsencrypt\/letsencrypt-auto certonly -a webroot --webroot-path=\/var\/www\/cctv.adomainname.com -d cctv.adomainname.com\r\n<\/pre>\n<h3>Generating a strong Diffie-Hellman group<\/h3>\n<p>After the SSL certificate and the corresponding private key were created successfully, I went on to precompute a strong Diffie-Hellman group for my server to use for exchanging cryptographic keys with its clients:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo openssl dhparam -out \/etc\/ssl\/certs\/dhparam.pem 2048\r\n<\/pre>\n<p>This process took a very long time to complete but it was worth the effort as it would make communicating with my server more secure.<\/p>\n<h3>Creating the nginx configurations for serving HTTPS on behalf of my Raspberry Pi Zero W CCTV camera<\/h3>\n<p>Once I had the corresponding SSL certificate artefacts for my sub domain, my nginx was ready for the corresponding configurations to serve HTTPS on behalf of my Raspberry Pi Zero W CCTV camera. The following is the last set of configurations that I included in <code>\/etc\/nginx\/sites-enabled\/cctv.adomainname.com.conf<\/code>. These set of configurations allows me to access my Raspberry Pi Zero W CCTV camera over HTTPS via my sub domain:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n# Redirect HTTP requests to HTTPS \r\nserver {\r\n\tlisten 80;\r\n\tserver_name  cctv.adomainname.com;\r\n\treturn 301 https:\/\/$host$request_uri;\r\n}\r\n\r\n# For ssl\r\nserver {\r\n\tssl on;\r\n\tssl_certificate \/etc\/letsencrypt\/live\/cctv.adomainname.com\/fullchain.pem;\r\n\tssl_certificate_key \/etc\/letsencrypt\/live\/cctv.adomainname.com\/privkey.pem;\r\n\tssl_protocols TLSv1 TLSv1.1 TLSv1.2;\r\n\tssl_prefer_server_ciphers on;\r\n\tssl_dhparam \/etc\/ssl\/certs\/dhparam.pem;\r\n\tssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';\r\n\tssl_session_timeout 1d;\r\n\tssl_session_cache shared:SSL:50m;\r\n\tssl_stapling on;\r\n\tssl_stapling_verify on;\r\n\tadd_header Strict-Transport-Security max-age=15768000;\r\n\t\r\n\tdefault_type  application\/octet-stream;\r\n\t\r\n\tlisten 443;\r\n\tserver_name  cctv.adomainname.com;\r\n\r\n\troot \/var\/www\/cctv.adomainname.com;\r\n\r\n\tlocation ~ \/.well-known {\r\n\t\tallow all;\r\n\t}\r\n\r\n\tlocation \/ {\r\n\t\tproxy_pass http:\/\/192.168.0.116;\r\n\t}\r\n}\r\n<\/pre>\n<h2>Buying your Raspberry Pi Zero W CCTV camera from Amazon<\/h2>\n<p>If you do not have the Raspberry Pi Zero W CCTV components mentioned in this post yet, you may want to purchase them from Amazon. Simply click on the button below to add the Raspberry Pi Zero W CCTV components to your cart. You may remove anything that you already have or replace some of the components with other components.<\/p>\n<p><center><\/p>\n<form action=\"https:\/\/www.amazon.com\/gp\/aws\/cart\/add.html\" method=\"GET\" target=\"_blank\"><input name=\"AssociateTag\" type=\"hidden\" value=\"clivsperswebs-20\"><input name=\"SubscriptionId\" type=\"hidden\" value=\"[AKIAIMND5UBCQU2HRSUA]\"><input name=\"ASIN.1\" type=\"hidden\" value=\"B06XD18H6K\"><input name=\"Quantity.1\" type=\"hidden\" value=\"1\"><input name=\"ASIN.2\" type=\"hidden\" value=\"B01ER2SKFS\"><input name=\"Quantity.2\" type=\"hidden\" value=\"1\"><input name=\"ASIN.3\" type=\"hidden\" value=\"B010Q57S62\"><input name=\"Quantity.3\" type=\"hidden\" value=\"1\"><br \/>\n<input alt=\"Buy from Amazon.com\" name=\"add\" type=\"image\" src=\"https:\/\/images-na.ssl-images-amazon.com\/images\/G\/01\/associates\/remote-buy-box\/buy4.gif\" value=\"Buy from Amazon.com\"><\/form>\n<p><\/center><\/p>\n<h2>Further enhancements for your Raspberry Pi Zero CCTV camera<\/h2>\n<p>If you want to make your Raspberry Pi Zero W CCTV camera see a wider view, you may want to get a pack of  <a href=\"https:\/\/www.amazon.com\/Fisheye-Magnetic-Camera-iPhone-Samsung\/dp\/B00Y2BEPR2\/ref=as_li_ss_tl?ie=UTF8&linkCode=ll1&tag=clivsperswebs-20&linkId=90e4fb21f439fb02d6a5ec3fbe16d765&language=en_US\" rel=\"noopener\" target=\"_blank\">Camera Lens Kit for mobile phones<\/a>. In case, you are curious about the effects of those lens, <a href=\"https:\/\/www.techcoil.com\/blog\/comparing-the-0-67x-wide-angle-lens-and-the-fisheye-lens-on-a-raspberry-pi-cctv\/\" rel=\"noopener\" target=\"_blank\">this is a comparison of the 0.67x wide angle lens and the Fisheye lens on a Raspberry Pi CCTV<\/a>.<\/p>\n<p>Since there is a 0.67x wide angle lens and a Fisheye lens in the pack, you will have the option to:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.techcoil.com\/blog\/how-to-turn-your-raspberry-pi-zero-w-cctv-into-a-wide-angle-security-camera\/\" rel=\"noopener\" target=\"_blank\">turn your Raspberry Pi Zero W CCTV into a wide angle security camera<\/a>.<\/li>\n<li><a href=\"https:\/\/www.techcoil.com\/blog\/how-to-make-your-raspberry-pi-zero-w-camera-see-an-ultra-wide-view\/\" rel=\"noopener\" target=\"_blank\">make your Raspberry Pi Zero W camera see an ultra-wide view<\/a>.<\/li>\n<\/ul>\n<h2>Reducing the number of false positives for your video recordings<\/h2>\n<p>When your surveillance area has a background with changes that you are not interested in capturing, your Raspberry Pi Zero W CCTV will create a lot of redundant video recordings. In such a situation, you may want to <a href=\"https:\/\/www.techcoil.com\/blog\/how-to-configure-motioneye-to-only-capture-video-if-there-are-movements-in-particular-sections-of-the-surveillance-area\/\" rel=\"noopener\" target=\"_blank\">configure motionEye to only capture video if there are movements in particular sections of the surveillance area<\/a>.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/How-to-setup-a-Raspberry-Pi-Zero-W-security-camera-with-motionEyeOS.jpg\" alt=\"How to setup a Raspberry Pi Zero W security camera with motionEyeOS\" \/><\/p>\n\n      <ul id=\"social-sharing-buttons-list\">\n        <li class=\"facebook\">\n          <a href=\"https:\/\/www.facebook.com\/sharer\/sharer.php?u=https%3A%2F%2Fwp.me%2Fp245TQ-af\" target=\"_blank\" role=\"button\" rel=\"nofollow\">\n            <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/Facebook.png\" alt=\"Facebook icon\"> Share\n          <\/a>\n        <\/li>\n        <li class=\"twitter\">\n          <a href=\"https:\/\/twitter.com\/intent\/tweet?text=&url=https%3A%2F%2Fwp.me%2Fp245TQ-af&via=Techcoil_com\" target=\"_blank\" role=\"button\" rel=\"nofollow\">\n          <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/Twitter.png\" alt=\"Twitter icon\"> Tweet\n          <\/a>\n        <\/li>\n        <li class=\"linkedin\">\n          <a href=\"https:\/\/www.linkedin.com\/shareArticle?mini=1&title=&url=https%3A%2F%2Fwp.me%2Fp245TQ-af&source=https:\/\/www.techcoil.com\" target=\"_blank\" role=\"button\" rel=\"nofollow\">\n          <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/linkedin.png\" alt=\"Linkedin icon\"> Share\n          <\/a>\n        <\/li>\n        <li class=\"pinterest\">\n          <a href=\"https:\/\/pinterest.com\/pin\/create\/button\/?url=https%3A%2F%2Fwww.techcoil.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F635&description=\" class=\"pin-it-button\" target=\"_blank\" role=\"button\" rel=\"nofollow\" count-layout=\"horizontal\">\n          <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/Pinterest.png\" alt=\"Pinterest icon\"> Save\n          <\/a>\n        <\/li>\n      <\/ul>\n    ","protected":false},"excerpt":{"rendered":"<p>When the <a href=\"https:\/\/www.amazon.com\/gp\/product\/B06XFZC3BX\/ref=as_li_tl?ie=UTF8&#038;tag=clivsperswebs-20&#038;camp=1789&#038;creative=9325&#038;linkCode=as2&#038;creativeASIN=B06XFZC3BX&#038;linkId=141ed8cff795cb56ba1e6bc4a7e2bc1e\" target=\"_blank\">Raspberry Pi Zero W<\/a> was launched, I didn&#8217;t think twice before ordering one. Compared to the Raspberry Pi Zero, the Raspberry Pi Zero W comes with WiFi. This meant that I can use my new Raspberry Pi Zero W to replace my <a href=\"https:\/\/www.techcoil.com\/blog\/how-i-built-my-home-raspberry-pi-3-cctv-using-a-motion-eye-os-image-from-home-surveillance\/\" target=\"_blank\">Raspberry Pi 3 CCTV camera<\/a> for home surveillance and use the more powerful Raspberry Pi 3 for other projects.<\/p>\n<p>This post documents how I setup my Raspberry Pi Zero W as a CCTV camera using the <a href=\"https:\/\/github.com\/ccrisan\/motioneyeos\" target=\"_blank\">MotionEyeOS<\/a> image.<\/p>\n","protected":false},"author":1,"featured_media":1198,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"footnotes":""},"categories":[4],"tags":[275,277,266,411,225,240,410,409,423,279],"jetpack_featured_media_url":"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/Raspberry-Pi-Zero-W-CCTV-held-by-mobile-phone-holder-clamped-to-desk.jpg","jetpack_shortlink":"https:\/\/wp.me\/p245TQ-af","jetpack-related-posts":[],"jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/posts\/635"}],"collection":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/comments?post=635"}],"version-history":[{"count":0,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/posts\/635\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/media\/1198"}],"wp:attachment":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/media?parent=635"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/categories?post=635"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/tags?post=635"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}