Lighttpd¶
Since the application is thought to be used for embedded devices, it’s recommended to use an embedded server. Lighttpd works well for this kind of application.
Note
Make sure the needed uWSGI service is working before configuring the server.
Installation¶
sudo apt install lighttpd
Configuration¶
Create a new configuration file /etc/lighttpd/conf-available/00-muscle-device.conf
with the following contents:
server.modules += (
"mod_scgi",
"mod_rewrite",
"mod_accesslog",
)
# Logfile - can be changed freely
accesslog.filename = "/tmp/muscle_access.log"
scgi.protocol = "uwsgi"
scgi.server = ("/muscle.uwsgi" =>
((
"socket" => "<PATH_TO_SOCKET>",
"check-local" => "disable",
"max-procs" => 1
))
)
# rewrite the url so the device can be accessed only with its IP
url.rewrite-once = (
"^(/.*)$" => "/muscle.uwsgi$1",
)
The value of <PATH_TO_SOCKET>
is configured in the devices muscle_device.ini
and defaults to /tmp/muscle_device.sock
. Replace it with the correct path.
Enable the Configuration¶
To enable the configuration, temporarily stop lighttpd and create a link to the just configured file:
sudo service lighttpd stop
sudo ln -s /etc/lighttpd/conf-available/00-muscle-device.conf /etc/lighttpd/conf-enabled
sudo service lighttpd start
This makes the device API available on port 80. The default port can be changed by changing server.port
in the global configuration /etc/lighttpd/lighttpd.conf
.