Skip to content

Commit

Permalink
Merge pull request #16 from flownative/custom-resolver
Browse files Browse the repository at this point in the history
BEACH_ASSET_PROXY_RESOLVER
  • Loading branch information
robertlemke committed Feb 3, 2023
2 parents a87b73f + f31fda4 commit e72cb0e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ for possible values. The default value is `warn`.
| BEACH_NGINX_CUSTOM_METRICS_TARGET_PORT | integer | 8082 | Port at which Nginx should listen to provide the metrics for scraping |
| BEACH_NGINX_MODE | string | Flow | Either "Flow" or "Static"; this variable is going to be renamed in the future |
| BEACH_ASSET_PROXY_ENDPOINT | string | | Endpoint of a cloud storage frontend to use for proxying requests to Flow persistent resources. Requires BEACH_PERSISTENT_RESOURCES_BASE_PATH to be set. Example: "https://assets.flownative.com/example-bucket/" |
| BEACH_ASSET_PROXY_RESOLVER | string | 8.8.8.8 | IP address of a DNS server to use for resolving domains when proxying assets. Set this to 127.0.0.11 when using Local Beach. |
| BEACH_PERSISTENT_RESOURCES_BASE_PATH | string | | Base path of URLs pointing to Flow persistent resources; example: "https://www.flownative.com/assets/" |
| BEACH_STATIC_RESOURCES_LIFETIME | string | 30d | Expiration time for static resources; examples: "3600s" or "7d" or "max" |
| 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 |
Expand Down
7 changes: 4 additions & 3 deletions root-files/opt/flownative/lib/nginx-legacy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ fi
export BEACH_PERSISTENT_RESOURCES_FALLBACK_BASE_URI=${BEACH_PERSISTENT_RESOURCES_FALLBACK_BASE_URI:-}
export BEACH_PERSISTENT_RESOURCES_BASE_PATH=${BEACH_PERSISTENT_RESOURCES_BASE_PATH:-/_Resources/Persistent/}
export BEACH_ASSET_PROXY_ENDPOINT=${BEACH_ASSET_PROXY_ENDPOINT:-}
export BEACH_ASSET_PROXY_RESOLVER=${BEACH_ASSET_PROXY_RESOLVER:-8.8.8.8}
export BEACH_PHP_FPM_HOST=${BEACH_PHP_FPM_HOST:-localhost}
export BEACH_PHP_FPM_PORT=${BEACH_PHP_FPM_PORT:-9000}
export BEACH_NGINX_MODE=${BEACH_NGINX_MODE:-Flow}
Expand Down Expand Up @@ -190,7 +191,7 @@ EOM
}
# pass persistent resource requests to the custom endpoint (S3, Minio, GCS ...)
location ~* "^${BEACH_PERSISTENT_RESOURCES_BASE_PATH}([a-f0-9]{40})/" {
resolver 8.8.8.8;
resolver ${BEACH_ASSET_PROXY_RESOLVER};
proxy_set_header Authorization "";
add_header Via 'Beach Asset Proxy';
${addHeaderStrictTransportSecurity}
Expand All @@ -207,7 +208,7 @@ EOM
}
# pass persistent resource requests to GCS
location ~* "^${BEACH_PERSISTENT_RESOURCES_BASE_PATH}([a-f0-9]{40})/" {
resolver 8.8.8.8;
resolver ${BEACH_ASSET_PROXY_RESOLVER};
proxy_set_header Authorization "";
add_header Via 'Beach Asset Proxy';
${addHeaderStrictTransportSecurity}
Expand All @@ -229,7 +230,7 @@ EOM
set \$assetUri ${BEACH_PERSISTENT_RESOURCES_FALLBACK_BASE_URI}\$1;
add_header Via 'Beach Asset Fallback';
${addHeaderStrictTransportSecurity}
resolver 8.8.8.8;
resolver ${BEACH_ASSET_PROXY_RESOLVER};
proxy_pass \$assetUri;
}
EOM
Expand Down

0 comments on commit e72cb0e

Please sign in to comment.