diff --git a/.github/workflows/web-server.yml b/.github/workflows/web-server.yml index c101039..fc36848 100644 --- a/.github/workflows/web-server.yml +++ b/.github/workflows/web-server.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - axis-os: ["11.7.57"] + axis-os: ["11.8.61"] arch: ["armv7hf", "aarch64"] env: EXREPO: acap-native-examples diff --git a/web-server/Dockerfile b/web-server/Dockerfile index 749d7d4..617f355 100644 --- a/web-server/Dockerfile +++ b/web-server/Dockerfile @@ -2,7 +2,7 @@ ARG ARCH=armv7hf ARG REPO=axisecp ARG SDK=acap-native-sdk ARG UBUNTU_VERSION=22.04 -ARG VERSION=1.11 +ARG VERSION=1.12 FROM ${REPO}/${SDK}:${VERSION}-${ARCH}-ubuntu${UBUNTU_VERSION} @@ -20,11 +20,11 @@ RUN git apply --ignore-space-change --ignore-whitespace ../monkey.patch &&\ --prefix=/usr/local \ --bindir=/usr/local/bin \ --libdir=/usr/local/lib \ - --sysconfdir=/usr/local/packages/monkey/html \ - --datadir=/usr/local/packages/monkey/html \ + --sysconfdir=/usr/local/packages/list/html \ + --datadir=/usr/local/packages/list/html \ --mandir=/usr/local/man \ --logdir=/tmp \ - --plugdir=/usr/local/packages/monkey/lib \ + --plugdir=/usr/local/packages/list/lib \ --pidfile=/tmp/monkey.pid \ --incdir=/usr/local/include/monkey \ --systemddir=/usr/lib/systemd/system &&\ @@ -40,9 +40,9 @@ RUN . /opt/axis/acapsdk/environment-setup* &&\ mkdir -p "$SDKTARGETSYSROOT"/usr/local &&\ cp -r /usr/local "$SDKTARGETSYSROOT"/usr &&\ mkdir -p lib &&\ - cp /usr/local/lib/libmonkey.so.1.5 /usr/local/packages/monkey/lib/*.so -t lib/ &&\ - cp -r /usr/local/packages/monkey/html . &&\ - acap-build . -a reverseproxy.conf + cp /usr/local/lib/libmonkey.so.1.5 /usr/local/packages/list/lib/*.so -t lib/ &&\ + cp -r /usr/local/packages/list/html . &&\ + acap-build . ENV PATH="${PATH}:/opt/axis/acapsdk/sysroots/x86_64-pokysdk-linux/usr/bin" ENTRYPOINT [ "/bin/bash" ] diff --git a/web-server/README.md b/web-server/README.md index 1a131ec..bfd8500 100644 --- a/web-server/README.md +++ b/web-server/README.md @@ -9,28 +9,28 @@ This example addresses a similar problem as the [web-server-using-fastcgi](../we [Reverse Proxy configuration](https://httpd.apache.org/docs/2.4/howto/reverse_proxy.html) provides a flexible way for an ACAP application to expose an external API through the Apache Server in AXIS OS and internally route the requests to a small Web Server running in the ACAP application. -Reverse Proxy is a technique that can be used for exposing many types of network APIs and can e.g. cover same cgi usecases as axHttp API. +**Reverse proxy** is a technique that can be used for exposing many types of network APIs and can e.g. cover the same CGI use cases as the old [AxHTTP](https://axiscommunications.github.io/acap-documentation/docs/acap-sdk-version-3/api/#http-api) API and is a different implementation to the [FastCGI](https://axiscommunications.github.io/acap-documentation/docs/api/native-sdk-api.html#fastcgi) API. -The Apache server is configured using post-install and pre-uninstall scripts features in a native ACAP. The post-install script adds a configuration file to apache configuration with reverse configuration for monkey server and applies it to Apache Server, and in the pre-uninstall the configuration is removed. +The Apache server is configured using the manifest.json file in an ACAP application. In manifest.json under `configuration`, it is possible to specify a `settingPage` and a `reverseProxy` where the latter will connect the Monkey server to the Apache server. -The Web Server running in the ACAP application can also be exposed directly to the network by allowing external access to the port in the network configuration for the device. There are some disavantages with exposing Web Server directly to the network such as non standard ports and no reuse of authentication, TLS and other features that comes with Apache Server. +The Web Server running in the ACAP application can also be exposed directly to the network by allowing external access to the port in the network configuration for the device. There are some disadvantages with exposing Web Server directly to the network such as non standard ports and no reuse of authentication, TLS and other features that comes with Apache Server. ## Monkey Web Server Monkey is a fast and lightweight Web Server for Linux. It has been designed to be very scalable with low memory and CPU consumption, the perfect solution for Embedded Linux and high end production environments. Besides the common features as HTTP server, it expose a flexible C API which aims to behave as a fully HTTP development framework, so it can be extended as desired through the plugins interface. The Monkey Web Server [documentation](http://monkey-project.com/documentation/1.5) describes the configuration in detail. +> [!NOTE] +> Currently, there's an issue with the Monkey web server when using the reverse proxy, impacting asset discovery. As a workaround, we're showcasing the `list` example. + ## Getting started -These instructions will guide you on how to execute the code. Below is the structure and scripts used in the example: +These instructions will guide you on how to execute the code. Below is the structure used in the example: ```sh web-server ├── app │ ├── LICENSE - Text file which lists all open source licensed source code distributed with the application -│ ├── manifest.json - Defines the application and its configuration -│ ├── postinstall.sh - Shell script for adding configration to apache -│ ├── preuninstall.sh - Shell script for removing configration to apache -│ └── reverseproxy.conf - Configuration for reverse proxy +│ └── manifest.json - Defines the application and its configuration ├── Dockerfile - Docker file with the specified Axis container image to build the example specified ├── monkey.patch - Patch for using monkey examples in a native ACAP └── README.md - Step by step instructions on how to run the example @@ -71,7 +71,7 @@ docker run --rm web-server:$ARCH eap-install.sh $DEVICE_IP $PASS install Goto your device web page > Click on the tab **Apps** in the device GUI and locate the application. Run the application by enabling the **Start** switch. -The Web Server can be accessed from a Web Browser eighter directly using a port number (i.e. http://:2001) or through the Apache Server in the device using an extension to the device web URL (i.e http:///monkey/index.html) or by using the Open button in the application page in the **Apps** tab. +The Web Server can be accessed from a Web Browser through the Apache Server in the device using an extension to the device web URL (i.e http:///local/list/server/) # Start your application from command line @@ -83,13 +83,6 @@ docker run --rm web-server:$ARCH eap-install.sh $DEVICE_IP $PASS stop docker run --rm web-server:$ARCH eap-install.sh $DEVICE_IP $PASS remove ``` -## C API Examples - -When you build the code, Some C API examples shall be copied into the app directory inside the build container. To build any of the examples, use the build and install procedure as described above after making following changes to the build files: - -1. app/manifest.json: Replace AppName "monkey" with the name of the example: hello, list or quiz -2. Dockerfile: Replace monkey in /usr/local/packages/monkey with the name of the example: hello, list or quiz - ## License **[Apache License 2.0](../LICENSE)** diff --git a/web-server/app/manifest.json b/web-server/app/manifest.json index 5dcfd6d..bc0338a 100644 --- a/web-server/app/manifest.json +++ b/web-server/app/manifest.json @@ -1,25 +1,21 @@ { - "schemaVersion": "1.4.0", - "acapPackageConf": { - "setup": { - "appName": "monkey", - "vendor": "Axis Communications", - "embeddedSdkVersion": "3.0", - "user": { - "username": "sdk", - "group": "sdk" - }, - "runMode": "never", - "version": "1.0.0" - }, - "installation": { - "postInstallScript": "postinstall.sh" - }, - "uninstallation": { - "preUninstallScript": "preuninstall.sh" - }, - "configuration": { - "settingPage": "index.html" - } - } -} \ No newline at end of file + "schemaVersion": "1.5.0", + "acapPackageConf": { + "setup": { + "appName": "list", + "vendor": "Axis Communications", + "embeddedSdkVersion": "3.0", + "runMode": "never", + "version": "1.0.0" + }, + "configuration": { + "reverseProxy": [ + { + "apiPath": "my_web_server", + "target": "http://localhost:2001", + "access": "admin" + } + ] + } + } +} diff --git a/web-server/app/postinstall.sh b/web-server/app/postinstall.sh deleted file mode 100644 index 2cd0443..0000000 --- a/web-server/app/postinstall.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -cp /usr/local/packages/monkey/reverseproxy.conf /etc/apache2/conf.d/reverseproxy.conf -systemctl reload httpd diff --git a/web-server/app/preuninstall.sh b/web-server/app/preuninstall.sh deleted file mode 100644 index 1d339b4..0000000 --- a/web-server/app/preuninstall.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -rm /etc/apache2/conf.d/reverseproxy.conf -systemctl reload httpd diff --git a/web-server/app/reverseproxy.conf b/web-server/app/reverseproxy.conf deleted file mode 100644 index c894e36..0000000 --- a/web-server/app/reverseproxy.conf +++ /dev/null @@ -1,2 +0,0 @@ -ProxyPass /monkey http://localhost:2001 -ProxyPassReverse /monkey http://localhost:2001