Skip to content

Commit 4d24759

Browse files
committed
Remove NodeJS support; Introduce NGINX_STATIC_ROOT
1 parent a34a52b commit 4d24759

File tree

2 files changed

+11
-38
lines changed

2 files changed

+11
-38
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ tbd.
2222

2323
## Hosting a static website
2424

25-
tbd.
25+
Set the environment variable "BEACH_NGINX_MODE" to "Static" and
26+
optionally set the variable "NGINX_STATIC_ROOT" to the path leading to
27+
the root of your static site.
28+
29+
The BEACH_NGINX_MODE variable follows legacy naming and will be renamed
30+
/ replaced by another concept in the future.
2631

2732
## Configuration
2833

@@ -53,9 +58,11 @@ for possible values. The default value is `warn`.
5358
| NGINX_CACHE_BACKGROUND_UPDATE | boolean | off | If background updates should be enabled |
5459
| NGINX_CUSTOM_ERROR_PAGE_CODES | string | 500 501 502 503 | FastCGI error codes which should redirect to the custom error page |
5560
| NGINX_CUSTOM_ERROR_PAGE_TARGET | string | | Upstream URL to use for custom FastCGI error pages |
61+
| NGINX_STATIC_ROOT | string | /var/www/html | Document root path for when BEACH_NGINX_MODE is "Static" |
5662
| BEACH_NGINX_CUSTOM_METRICS_ENABLE | boolean | no | If support for a custom metrics endpoint should be enabled |
5763
| BEACH_NGINX_CUSTOM_METRICS_SOURCE_PATH | string | /metrics | Path where metrics are located |
5864
| BEACH_NGINX_CUSTOM_METRICS_TARGET_PORT | integer | 8082 | Port at which Nginx should listen to provide the metrics for scraping |
65+
| BEACH_NGINX_MODE | string | Flow | Either "Flow" or "Static"; this variable is going to be renamed in the future |
5966
| FLOW_HTTP_TRUSTED_PROXIES | string | 10.0.0.0/8 | Nginx passes FLOW_HTTP_TRUSTED_PROXIES to the virtual host using the value of this variable |
6067

6168
## Security aspects

root-files/opt/flownative/lib/nginx-legacy.sh

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ export BEACH_NGINX_CUSTOM_METRICS_TARGET_PORT=${BEACH_NGINX_CUSTOM_METRICS_TARGE
5858
5959
export NGINX_CUSTOM_ERROR_PAGE_TARGET=${NGINX_CUSTOM_ERROR_PAGE_TARGET:-${BEACH_NGINX_CUSTOM_ERROR_PAGE_TARGET:-}}
6060
61-
export NGINX_UPSTREAM_HOST=${NGINX_UPSTREAM_HOST:-127.0.0.1}
62-
export NGINX_UPSTREAM_PORT=${NGINX_UPSTREAM_PORT:-3000}
61+
export NGINX_STATIC_ROOT=${NGINX_STATIC_ROOT:-/var/www/html}
6362
EOF
6463
}
6564

@@ -173,50 +172,19 @@ EOM
173172
EOM
174173
}
175174

176-
# ---------------------------------------------------------------------------------------
177-
# nginx_legacy_initialize_nodejs() - Set up Nginx configuration for NodeJS
178-
#
179-
# @global NGINX_* The NGINX_* environment variables
180-
# @return void
181-
#
182-
nginx_legacy_initialize_nodejs() {
183-
info "Nginx: Enabling site configuration for NodeJS ..."
184-
cat >"${NGINX_CONF_PATH}/sites-enabled/nodejs.conf" <<-EOM
185-
upstream nodejs {
186-
server ${NGINX_UPSTREAM_HOST}:${NGINX_UPSTREAM_PORT};
187-
keepalive 8;
188-
}
189-
190-
server {
191-
listen *:8080 default_server;
192-
193-
add_header Via '\$hostname';
194-
195-
location / {
196-
proxy_set_header X-Real-IP \$remote_addr;
197-
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
198-
proxy_set_header Host \$http_host;
199-
200-
proxy_pass http://nodejs/;
201-
proxy_redirect off;
202-
}
203-
}
204-
EOM
205-
}
206-
207175
# ---------------------------------------------------------------------------------------
208176
# nginx_legacy_initialize_static() - Set up Nginx configuration for a static site
209177
#
210178
# @global NGINX_* The NGINX_* environment variables
211179
# @return void
212180
#
213181
nginx_legacy_initialize_static() {
214-
info "Nginx: Enabling default site configuration ..."
182+
info "Nginx: Enabling static site configuration with root at ${NGINX_STATIC_ROOT} ..."
215183
cat >"${NGINX_CONF_PATH}/sites-enabled/default.conf" <<-EOM
216184
server {
217185
listen *:8080 default_server;
218186
219-
root /var/www/html;
187+
root ${NGINX_STATIC_ROOT};
220188
221189
# deny files starting with a dot (having "/." in the path)
222190
location ~ /\\. {
@@ -308,8 +276,6 @@ nginx_legacy_initialize() {
308276

309277
if [ "$BEACH_NGINX_MODE" == "Flow" ]; then
310278
nginx_legacy_initialize_flow
311-
elif [ "$BEACH_NGINX_MODE" == "NodeJS" ]; then
312-
nginx_legacy_initialize_nodejs
313279
else
314280
nginx_legacy_initialize_static
315281
fi

0 commit comments

Comments
 (0)