summaryrefslogtreecommitdiffstats
path: root/meta-openbmc-machines
diff options
context:
space:
mode:
authorDeepak Kodihalli <dkodihal@in.ibm.com>2018-07-30 03:41:43 -0500
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2018-08-21 19:30:29 +0000
commitef18a48d23e7fcaef501166b0766680519846272 (patch)
treef1cf207f04249e254d778469b328724856ebea36 /meta-openbmc-machines
parented734e8c838ce77fd01aa8e9d54f47145b828f37 (diff)
downloadtalos-openbmc-ef18a48d23e7fcaef501166b0766680519846272.tar.gz
talos-openbmc-ef18a48d23e7fcaef501166b0766680519846272.zip
webui: serve via nginx
Serve the mostly pre-compressed static webui content via nginx. If nginx can't find a static file, proxy the URI back to the rest server. A follow-up commit will remove code that serves webui from the phosphor-rest-server. Tested: - The webui, rest server and bmcweb seem to be working as before. - curl -H "Accept-Encoding: gzip" https://<witherspoon>/foo.html is served compressed content. - curl https://<witherspoon>/foo.html is served uncompressed content. Change-Id: Ice443f00a467f3558f28d697261df4f23278f420 Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
Diffstat (limited to 'meta-openbmc-machines')
-rw-r--r--meta-openbmc-machines/meta-openpower/common/recipes-phosphor/webui/phosphor-webui.bbappend16
-rw-r--r--meta-openbmc-machines/meta-openpower/meta-ibm/recipes-httpd/nginx/files/nginx.conf19
-rw-r--r--meta-openbmc-machines/meta-openpower/meta-ibm/recipes-httpd/nginx/nginx_%.bbappend2
3 files changed, 35 insertions, 2 deletions
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/webui/phosphor-webui.bbappend b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/webui/phosphor-webui.bbappend
new file mode 100644
index 000000000..ea818947e
--- /dev/null
+++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/webui/phosphor-webui.bbappend
@@ -0,0 +1,16 @@
+do_install_append () {
+
+# The webui content is served as pre-compressed gzip content. While nginx can
+# handle this via the gzip_static directive (and we use that), the nginx
+# try_files directive (which we also use) searches the URI as-is. The suggested
+# workaround is to have an empty uncompressed file with the same name as the
+# compressed file. This does not impact the functionality of gzip_static.
+# So for eg if there's an index.html.gz, create an empty index.html. Same goes
+# for all the webui content.
+# https://serverfault.com/questions/571733/nginx-gzip-static-why-are-the-non-compressed-files-required
+# https://www.ruby-forum.com/topic/4402481
+# https://trac.nginx.org/nginx/ticket/1367
+
+find ${D}${datadir}/www -type f -name '*.gz' -exec sh -c 'touch `dirname "$0"`/`basename "$0" .gz`' '{}' \;
+
+}
diff --git a/meta-openbmc-machines/meta-openpower/meta-ibm/recipes-httpd/nginx/files/nginx.conf b/meta-openbmc-machines/meta-openpower/meta-ibm/recipes-httpd/nginx/files/nginx.conf
index 89e575af5..7d65183ec 100644
--- a/meta-openbmc-machines/meta-openpower/meta-ibm/recipes-httpd/nginx/files/nginx.conf
+++ b/meta-openbmc-machines/meta-openpower/meta-ibm/recipes-httpd/nginx/files/nginx.conf
@@ -65,12 +65,29 @@ http {
ssl_prefer_server_ciphers on;
location / {
+ # This location lets us serve the static pre-compressed webui
+ # content (rooted at /usr/share/www). Also if the URI points to
+ # something else (that is unmatched by other locations), we
+ # fallback to the rest server. This approach is based on the
+ # guide at https://docs.nginx.com/nginx/admin-guide/web-server/serving-static-content.
+ root /usr/share/www;
+ # For clients that support gzip encoding, serve them
+ # pre-compressed gzip content. For clients that don't,
+ # uncompress on the BMC. The module gunzip requires
+ # gzip_static to be set to 'always'; gzip_static is the
+ # module that serves compressed content for clients that
+ # support gzip.
+ gunzip on;
+ gzip_static always;
+ try_files $uri $uri/ @rest_server;
+ }
+ location @rest_server {
# Use 127.0.0.1 instead of localhost since nginx will
# first use ipv6 address of ::1 which the upstream server
# is not listening on. This generates an error msg to
# the journal. Nginx then uses the 127.0.0.1 and everything
# works fine but want to avoid the error msg to the log.
- proxy_pass http://127.0.0.1:8081/;
+ proxy_pass http://127.0.0.1:8081;
# WebSocket support
proxy_http_version 1.1;
diff --git a/meta-openbmc-machines/meta-openpower/meta-ibm/recipes-httpd/nginx/nginx_%.bbappend b/meta-openbmc-machines/meta-openpower/meta-ibm/recipes-httpd/nginx/nginx_%.bbappend
index 8a58341ea..8eb7e402b 100644
--- a/meta-openbmc-machines/meta-openpower/meta-ibm/recipes-httpd/nginx/nginx_%.bbappend
+++ b/meta-openbmc-machines/meta-openpower/meta-ibm/recipes-httpd/nginx/nginx_%.bbappend
@@ -9,7 +9,7 @@ SRC_URI += " \
file://gen-cert.sh \
"
-EXTRA_OECONF =+ " --without-select_module"
+EXTRA_OECONF =+ " --without-select_module --with-http_gunzip_module"
SSLCERTPATH = "/etc/ssl/certs/nginx/"
OpenPOWER on IntegriCloud