kopia lustrzana https://github.com/piku/piku
Include a custom nginx config fragment with NGINX_INCLUDE_FILE (#79)
* Refactor common config out of nginx templates. * A way to inject custom nginx directives. Setting the ENV variable `NGINX_INCLUDE_FILE` allows the user to specify a file, relative to the app folder, which will be inserted into the nginx server config. This is useful for e.g. overriding a variable. For example to allow uploads larger than 1Mb the user could create a file called `nginx.conf` in their app repo containing: `client_max_body_size 8M;` and then set `NGINX_INCLUDE_FILE=nginx.conf` in the ENV file. This builds on #77 so that should be merged first.pull/80/head
rodzic
dca9342b2e
commit
90d20dac28
|
@ -36,4 +36,5 @@ You can configure deployment settings by placing special variables in an `ENV` f
|
|||
* `NGINX_CLOUDFLARE_ACL` (boolean): activate an ACL allowing access only from Cloudflare IPs
|
||||
* `NGINX_STATIC_PATHS`: set an array of `/url:path` values
|
||||
* `NGINX_HTTPS_ONLY`: tell nginx to auto-redirect non-SSL traffic to SSL site
|
||||
* `NGINX_INCLUDE_FILE`: a file in the app's dir to include in nginx config `server` section - useful for including custom nginx directives.
|
||||
* `NGINX_ALLOW_GIT_FOLDERS`: (boolean) allow access to `.git` folders (default: false, blocked)
|
||||
|
|
3
piku.py
3
piku.py
|
@ -117,6 +117,8 @@ NGINX_COMMON_FRAGMENT = """
|
|||
# set a custom header for requests
|
||||
add_header X-Deployed-By Piku;
|
||||
|
||||
$NGINX_CUSTOM_CLAUSES
|
||||
|
||||
$INTERNAL_NGINX_STATIC_MAPPINGS
|
||||
|
||||
$NGINX_BLOCK_GIT
|
||||
|
@ -619,6 +621,7 @@ def spawn_app(app, deltas={}):
|
|||
echo("Error {} in static path spec: should be /url1:path1[,/url2:path2], ignoring.".format(e))
|
||||
env['INTERNAL_NGINX_STATIC_MAPPINGS'] = ''
|
||||
|
||||
env['NGINX_CUSTOM_CLAUSES'] = expandvars(open(join(app_path, env["NGINX_INCLUDE_FILE"])).read(), env) if env.get("NGINX_INCLUDE_FILE") else ""
|
||||
env['NGINX_COMMON'] = expandvars(NGINX_COMMON_FRAGMENT, env)
|
||||
|
||||
echo("-----> nginx will map app '{}' to hostname '{}'".format(app, env['NGINX_SERVER_NAME']))
|
||||
|
|
Ładowanie…
Reference in New Issue