New feature: provide location order (#24 related)

pull/27/head 1.3.3
Emilien Mantel 2016-11-23 11:43:13 +01:00
parent de71e1bdcc
commit 5b0977567c
4 changed files with 18 additions and 4 deletions

View File

@ -13,7 +13,7 @@ Features:
- Fast PHP configuration - Fast PHP configuration
- Preconfigured vhost templates (should work on many app) - Preconfigured vhost templates (should work on many app)
- Auto-configure HTTP2 on SSL/TLS vhosts - Auto-configure HTTP2 on SSL/TLS vhosts
- Manage dynamic modules (install and loading) - Manage dynamic modules (install and loading)
Requirements Requirements
------------ ------------

View File

@ -18,6 +18,7 @@ Common
- `redirect_to_code`: Redirect code (default: 302) - `redirect_to_code`: Redirect code (default: 302)
- `redirect_https`: (O) Boolean. Redirect HTTP to HTTPS. If "true", you _MUST_ set `proto` to ```['https']```. - `redirect_https`: (O) Boolean. Redirect HTTP to HTTPS. If "true", you _MUST_ set `proto` to ```['https']```.
- `location`: (O) Add new custom locations (it does not overwrite!) - `location`: (O) Add new custom locations (it does not overwrite!)
- `location_order`: (O) Due to non preditive `location` order, you can provide the good order (see test-location.local in [tests/test.yml](../tests/test.yml)).
- `more`: (O) Add more custom infos. - `more`: (O) Add more custom infos.
- `upstream_params`: (O) Add upstream params (useful when you want to pass variables to PHP) - `upstream_params`: (O) Add upstream params (useful when you want to pass variables to PHP)
- `override_try_files`: (O) overrides default try\_files defined in template - `override_try_files`: (O) overrides default try\_files defined in template
@ -25,7 +26,7 @@ Common
- `htpasswd`: (O) References name key in `nginx_htpasswd`. Enable auth basic on all vhost. - `htpasswd`: (O) References name key in `nginx_htpasswd`. Enable auth basic on all vhost.
- `proto`: (O) list of protocol used. Default is a list with "http". If you need http and https, you must set a list with "http" and "https". You can only set "https" without http support. - `proto`: (O) list of protocol used. Default is a list with "http". If you need http and https, you must set a list with "http" and "https". You can only set "https" without http support.
- `ssl_name`: (D) name of the key used when using TLS/SSL. Optional when `proto` contains "https". If you don't set this value, it will search by `name`. - `ssl_name`: (D) name of the key used when using TLS/SSL. Optional when `proto` contains "https". If you don't set this value, it will search by `name`.
- `ssl_template` (O) "strong" (default) or "legacy". You can disable SSL helpers and add your own directives by setting "false". - `ssl_template` (O) "strong" (default) or "legacy". You can disable SSL helpers and add your own directives by setting "false".
- `php_version` (O) Sepecify PHP version (5 or 7) - `php_version` (O) Sepecify PHP version (5 or 7)
(O): Optional (O): Optional

View File

@ -5,6 +5,7 @@
{% set __location = item.location | default({}) %} {% set __location = item.location | default({}) %}
{% set __headers = item.headers | default({'X-Frame-Options': 'DENY always', 'X-Content-Type-Options': 'nosniff always' }) %} {% set __headers = item.headers | default({'X-Frame-Options': 'DENY always', 'X-Content-Type-Options': 'nosniff always' }) %}
{% set __ssl_name = item.ssl_name | default(item.name if item.name is string else item.name[0]) %} {% set __ssl_name = item.ssl_name | default(item.name if item.name is string else item.name[0]) %}
{% set __location_order = item.location_order | default(__location.keys()) %}
{% macro htpasswd(htpasswd_name, indent=1) -%} {% macro htpasswd(htpasswd_name, indent=1) -%}
{% for ht in nginx_htpasswd if ht.name == htpasswd_name %} {% for ht in nginx_htpasswd if ht.name == htpasswd_name %}
{{ "\t" * indent }}auth_basic "{{ ht.description }}"; {{ "\t" * indent }}auth_basic "{{ ht.description }}";
@ -84,10 +85,11 @@ server {
{% block template_custom_location %} {% block template_custom_location %}
{% endblock %} {% endblock %}
{% if __location is iterable and __location | length > 0 %} {% if __location_order | length > 0 %}
# --> Custom locations # --> Custom locations
{% for location, opts in __location.iteritems() %} {% for location in __location_order %}
location {{ location }} { location {{ location }} {
{% set opts = __location[location] %}
{% for opt in opts %} {% for opt in opts %}
{% if opt.htpasswd is defined %}{{ htpasswd(opt.htpasswd, 2) }}{% else %} {% if opt.htpasswd is defined %}{{ htpasswd(opt.htpasswd, 2) }}{% else %}
{{ opt }} {{ opt }}

View File

@ -155,6 +155,17 @@
location: location:
'/': '/':
- 'alias /var/tmp;' - 'alias /var/tmp;'
'/a':
- 'alias /var/tmp;'
'/b':
- 'alias /var/tmp;'
'/c':
- 'alias /var/tmp;'
location_order:
- '/'
- '/a'
- '/b'
- '/c'
- name: 'test-php.local' - name: 'test-php.local'
php_version: "{{ '7.0' if nginx_php70 else '5.6' }}" php_version: "{{ '7.0' if nginx_php70 else '5.6' }}"
upstream_params: upstream_params: