Hosting configuration
Nginx
Install nginx via sudo apt-get install nginx
Create /etc/nginx/sites-available/automation-controller. Then add the code below:
server {
listen 80;
server_name _;
location / {
proxy_pass http://localhost:7136;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /ioTHub {
proxy_pass http://localhost:5136;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Install ufw via sudo apt-get install ufw
, then run:
sudo ufw allow 'Nginx Full'
sudo ufw allow 1880
sudo ufw allow 3000
Node-RED
sudo systemctl enable nodered.service
More info: https://nodered.org/docs/getting-started/raspberrypi
Grafana
sudo /bin/systemctl enable grafana-server
sudo /bin/systemctl start grafana-server
More info: https://grafana.com/tutorials/install-grafana-on-raspberry-pi/
Automation Controller Core App
Publish a self-contained application, preferably with next profile settings:
- Configuration: Release
- Target framework: net8.0
- Deployment-mode: Self-contained
- Target runtime: linux-arm64
- Toggle on “Produce single file”
Copy files to the /var/www/html/iot-electronics
Create /etc/systemd/system/automation-controller.service
. Then add the code below:
[Unit]
Description=IoTElectronics.AutomationController
[Service]
WorkingDirectory=/var/www/html/iot-electronics
ExecStart=/var/www/html/iot-electronics/IoT.RPiController.WebApi
Restart=always
RestartSec=10
SyslogIdentifier=IoT.RPiController.WebApi
User=pi
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
Environment=ASPNETCORE_URLS=http://localhost:7136;http://localhost:5136
[Install]
WantedBy=multi-user.target
Finally enable and start the service:
sudo systemctl enable automation-controller.service
sudo systemctl start automation-controller.service