__netbox_uwsgi: add --serve-static parameter

New option to directly serve static content via uWSGI.
This commit is contained in:
matze 2020-09-05 21:48:04 +02:00
parent 5a403de057
commit ffba3ae776
4 changed files with 28 additions and 1 deletions

View File

@ -43,9 +43,20 @@ if [ -z "$socket_changes" ]; then
fi
# multi-process settings
cat << EOF
; processes and threads
processes = $(( 2*cores + 1 ))
threads = 2
EOF
# optional mapping of static content
if [ "$STATIC_MAP" != "" ]; then
cat << EOF
; map static content
static-map = /static=/opt/netbox/netbox/static
EOF
fi

View File

@ -38,7 +38,12 @@ scgi-bind
BOOLEAN PARAMETERS
------------------
None.
serve-static
Setup uWSGI to serve the static content, too. This is generally not
recommended for real production setups, as it is the job of the reverse
proxy server, who will thread it as static cachable content. This option
is only recommended for small setups or direct usage of the uWSGI socket
like using it as standalone HTTP server for NetBox.
MESSAGES
@ -76,6 +81,10 @@ EXAMPLES
--http-bind 0.0.0.0:8080 \
--fastcgi-bind 1.2.3.4:5678
# as standalone server
__netbox $args
require="__netbox" __netbox_uwsgi --serve-static --http-bind 0.0.0.0:80
SEE ALSO
--------

View File

@ -1,5 +1,11 @@
#!/bin/sh -e
# *bind* parameters are directly processed in the gen script
if [ -f "$__object/parameter/serve-static" ]; then
STATIC_MAP="yes"
export STATIC_MAP
fi
# process template
mkdir "$__object/files"
"$__type/files/uwsgi.ini.sh" > "$__object/files/uwsgi.ini"

View File

@ -0,0 +1 @@
serve-static