11* Copyright (C) 2021, Axis Communications AB, Lund, Sweden. All Rights Reserved.*
22
3- # Serve HTTP requests in an ACAP application
3+ # Serve HTTP requests through reverse proxy
44
55This example demonstrates how to setup the Axis device web server (Apache) in a
66[ Reverse Proxy] ( https://httpd.apache.org/docs/2.4/howto/reverse_proxy.html )
77configuration, where HTTP requests to the application are routed to a web server
8- [ Monkey] ( https://github.com/monkey/monkey ) running in the ACAP application and
9- acting as a CGI.
8+ [ Monkey] ( https://github.com/monkey/monkey ) running inside the ACAP application
9+ and acting as a CGI.
10+
11+ The advantage of a webserver proxy is that when porting existing code to your
12+ ACAP application, its request handling can remain largely unmodified. This eases
13+ the task of sharing code between platforms. The webserver proxy method enforces
14+ a URL routing scheme as follows:
15+
16+ ` http://<AXIS_DEVICE_IP>/local/<appName>/<apiPath> `
17+
18+ With ` <appName> ` and ` <apiPath> ` as defined in the manifest.
19+
20+ Note that this example shows the reverse proxy concept using Monkey, but you are
21+ free to use any webserver of your choice.
1022
1123## Alternative approach
1224
@@ -27,6 +39,12 @@ application. In `manifest.json` under `configuration`, it is possible to specify
2739a ` settingPage ` and a ` reverseProxy ` where the latter will connect the Monkey
2840server to the Apache server.
2941
42+ Prior to manifest 1.5.0, reverse proxy was only supported through the
43+ postinstall script. The manifest based method is more strict on URLs in order to
44+ avoid name clashes that could occur in the old mechanism. When upgrading, your
45+ URLs will change to the format shown in
46+ [ Serve HTTP requests through reverse proxy] ( #serve-http-requests-through-reverse-proxy ) .
47+
3048The web server running in the ACAP application can also be exposed directly to
3149the network by allowing external access to the port in the network
3250configuration for the device. There are disadvantages with exposing Web
@@ -68,7 +86,7 @@ web-server
6886
6987- Apache Reverse Proxy can not translate content with absolute addresses (i.e.
7088 /image.png) in the HTML page. Use only relative content (i.e. image.png or
71- ../image.png)) . More information how to handle relative URLs correctly with a
89+ ../image.png). More information how to handle relative URLs correctly with a
7290reverse proxy
7391[here](https://serverfault.com/questions/561892/how-to-handle-relative-urls-correctly-with-a-reverse-proxy).
7492
@@ -145,11 +163,6 @@ As can be seen it's HTML code, browse to web page
145163`http://<AXIS_DEVICE_IP>/local/web_server_rev_proxy/my_web_server`
146164for seeing it rendered.
147165
148- > [!NOTE]
149- >
150- > - The API path is `<AXIS_DEVICE_IP>/local/<appName>/<apiPath>` where
151- > `appName` and `apiPath` are fields from `manifest.json`.
152-
153166The application log can be found by either
154167
155168- Browse to `http://<AXIS_DEVICE_IP>/axis-cgi/admin/systemlog.cgi?appname=web_server_rev_proxy`.
0 commit comments