-
Notifications
You must be signed in to change notification settings - Fork 7
InstallationWebInterfaceNginx
The following instructions were provided by Seri Al-Najjar for using Nginx instead of Apache. Follow the instructions for Logging to a Database before continuing.
As the Heatmiser-WiFi Perl web interface uses CGI scripts, and nginx only supports FCGI, to be able to get everything to work together, we need another server or daemon that nginx can talk to and proxy the CGI access to.
The most lightweight solution I found for this was to UWSGI (be sure to check that your nginx install was built with uwsgi support).
These instructions have been used and tested on Gentoo, however, it shouldn't be too complicated to modify them for other Linux distributions.
Install uwsgi if you haven't done so already:
emerge -av uwsgi```
Once installed, create an application specific configuration for proxying & interpreting CGI files:
```sh
cp /etc/conf.d/uwsgi /etc/conf.d/uwsgi.cgi```
Modify the following lines in the `/etc/conf.d/uwsgi.cgi` file:
```sh
UWSGI_PROGRAM=/var/www/localhost/uwsgi
UWSGI_XML_CONFIG=/var/www/localhost/uwsgi/cgi/config/config.xml
UWSGI_LOG_FILE=/var/log/uwsgi/uwsgi.cgi.log```
Create a folder structure to hold our UWSGI application and configuration:
```sh
mkdir -p /var/www/localhost/uwsgi/cgi/config```
Create a configuration XML file for CGI proxying, this configuration file instructs UWSGI to listen on the loopback adapter on port `3128`, to present a virtual `/cgi-bin` directory that serves the files located in `/var/www/localhost/cgi-bin`, and lastly, to only serve files that end with a `.cgi` or `.pl` extension:
```sh
vi /var/www/localhost/uwsgi/cgi/config/config.xml```
```xml
<uwsgi>
<plugins>cgi
Unknown end tag for </plugins>
<socket>127.0.0.1:3128
Unknown end tag for </socket>
<cgi>/cgi-bin=/var/www/localhost/cgi-bin
Unknown end tag for </cgi>
<cgi-allowed-ext>.cgi
Unknown end tag for </cgi-allowed-ext>
<cgi-allowed-ext>.pl
Unknown end tag for </cgi-allowed-ext>
Unknown end tag for </uwsgi>
Lastly, create a init script instance to start the UWSGI CGI application, set it to start at boot and then start it manually for the time being:
cp /etc/init.d/uwsgi /etc/init.d/uwsgi.cgi
rc-update add uwsgi.cgi default
rc-service uwsgi.cgi start```
UWSGI should now be fully configured and functional, listening on port `3128` and serving any CGI files that are located in `/var/www/localhost/cgi-bin`.
## Configuring NGINX to interface with UWSGI ##
Update your NGINX configurations HTTP section to add the following alias and redirect:
```text
location ~ /cgi-bin {
include uwsgi_params;
uwsgi_param REDIRECT_STATUS 200;
uwsgi_modifier1 9;
uwsgi_pass 127.0.0.1:3128;
}```
And restart NGINX:
```sh
rc-service nginx restart```
## Configuring the Heatmiser Perl Web Application ##
From the heatmiser-wifi/bin directory, copy the following files into the web cgi-bin directory (`/var/www/localhost/cgi-bin/`):
* `ajax.pl`
* `heatmiser_config.pm`
* `heatmiser_db.pm`
From the `heatmiser-wifi/bin` directory, copy the `index.html` file to whatever directory in your web root you want to make the interface available from (i.e.):
```sh
mkdir /var/www/localhost/htdocs/thermostat/
cp theheatmiser-wifi/bin/index.html /var/www/localhost/htdocs/thermostat/index.html```
And download the jQuery and Highcharts Highstock JavaScript libraries:
```sh
wget http://code.jquery.com/jquery-2.0.2.min.js -O /var/www/localhost/htdocs/thermostat/jquery-2.0.2.min.js
wget http://code.highcharts.com/stock/1.3.2/highstock.src.js -O /var/www/localhost/htdocs/thermostat/highstock.js```
You should now be able to browse to your server/thermostat to view the web interface.
Home | Installation | Troubleshooting | Contact | © Copyright 2011-2015 Alexander Thoukydides
Due to Heatmiser's lack of support for their pre-Neo models I have replaced mine with a Nest Learning Thermostat (3rd generation).
- Project Home
- Installation Instructions
- Reference Information
- Acknowledgements
- Contact
- Heatmiser Websites
- Related Projects
- Other Resources