Configure nginx web server ========================== .. warning:: This section depens on configuration of gunicorn web server. Check previous section to resolve problems. Step 1 - Create custom recipe ----------------------------- As gunicorn, nginx web server is basic functionality of the system. Custom recipe which will append to default nginx's recipe will be placed inside ``recipes-base`` folder. .. code-block:: mkdir -p ../meta-golemos/recipes-base/nginx/files touch ../meta-golemos/recipes-base/nginx/nginx_%.bbappend In this custom recipe place this instructions. .. code-block:: FILESEXTRAPATHS_prepend := "${THISDIR}/files:" SRC_URI += " \ file://datalogger.local \ file://datalogger-setup.local \ " SYSTEMD_AUTO_ENABLE = "enable" SYSTEMD_SERVICE__append = " nginx.service " do_install_append () { install -d ${D}${sysconfdir}/nginx/sites-available install -D -m 644 ${WORKDIR}/datalogger.local ${D}${sysconfdir}/nginx/sites-available/ install -D -m 644 ${WORKDIR}/datalogger-setup.local ${D}${sysconfdir}/nginx/sites-available/ rm -rf ${D}${sysconfdir}/nginx/sites-enabled/default_server ln -s ${sysconfdir}/nginx/sites-available/datalogger-setup.local ${D}${sysconfdir}/nginx/sites-enabled/ } .. note:: This configuration remove default server from ``sites-enabled`` and place setup page as a default server. .. note:: Original recipe is only available inside ``meta-webserver`` layer. Check dependency section to learn how to satisfy dependencies. Step 2 - Create configuration files ----------------------------------- Inside files folder create two configuration files. One will be for setup page and other will be for main page after setting up the device. Main page ^^^^^^^^^ .. code-block:: touch ../meta-golemos/recipes-base/nginx/files/datalogger.local Output for ``datalogger.local`` file: .. code-block:: server { listen 80 default_server; listen [::]:80 default_server; root /var/www/datalogger.local; index index.html index.htm; server_name datalogger.local; location / { try_files $uri $uri/ =404; } } Setup page ^^^^^^^^^^ .. code-block:: touch ../meta-golemos/recipes-base/nginx/files/datalogger-setup.local Output for ``datalogger-setup.local`` file: .. code-block:: server { listen 80 default_server; listen [::]:80 default_server; server_name datalogger-setup.local; location / { proxy_pass http://unix:/run/datalogger_setup_page.sock; } } Summary ------- From now you can write device IP inside browser and see websites hosted on custom Linux distribution. After all of this steps your layer structure should look like this. .. code-block:: ../meta-golemos ├── COPYING.MIT ├── README ├── conf │   ├── bblayers.conf.sample │   ├── conf-notes.txt │   ├── distro │   │   └── golemos.conf │   ├── layer.conf │   └── local.conf.sample ├── recipes-base │   ├── datalogger-setup-page │   │   └── datalogger-setup-page.bb │   ├── nginx │   │   ├── files │   │   │   ├── datalogger-setup.local │   │   │   └── datalogger.local │   │   └── nginx_%.bbappend │   └── python3-gunicorn │   ├── files │   │   ├── datalogger_setup_page.service │   │   └── datalogger_setup_page.socket │   └── python3-gunicorn_%.bbappend ├── recipes-connectivity │   ├── hostapd │   │   ├── files │   │   │   ├── hostapd@.service │   │   │   └── wlan0.conf │   │   └── hostapd_%.bbappend │   ├── kea │   │   ├── files │   │   │   ├── kea-dhcp4.conf │   │   │   └── kea-dhcp4.service │   │   └── kea_%.bbappend │   └── wpa-supplicant │   ├── files │   │   └── wpa_supplicant-nl80211-wlan0.conf │   └── wpa-supplicant_%.bbappend ├── recipes-core │   ├── images │   │   ├── datalogger-dev-image.bb │   │   ├── datalogger-extended-image.bb │   │   └── datalogger-image.bb │   ├── packagegroups │   │   ├── datalogger-base-packagegroup.bb │   │   ├── datalogger-core-packagegroup.bb │   │   ├── datalogger-dev-packagegroup.bb │   │   └── datalogger-extended-packagegroup.bb │   ├── systemd │   │   └── systemd_%.bbappend │   └── systemd-conf │   ├── files │   │   └── wlan.network │   └── systemd-conf_%.bbappend └── recipes-example └── example └── example_0.1.bb