Add nginx path_prefix in proxy_pass (#871)

* Add path_prefix field for nginx plugin
* Add path_prefix ngninx plugin
* Update Nginx.xml
* Update location.xml
* Update index.volt
* Update SettingsController.php
* review comments
This commit is contained in:
Carlos Cesario
2018-09-26 18:58:53 +02:00
committed by Fabian Franz BSc
parent 8e687eed3e
commit 74b046056a
5 changed files with 16 additions and 2 deletions
@@ -147,7 +147,7 @@ class SettingsController extends ApiMutableModelControllerBase
// Location
public function searchlocationAction()
{
return $this->searchBase('location', array('description','urlpattern', 'matchtype', 'enable_secrules', 'force_https'));
return $this->searchBase('location', array('description','urlpattern', 'path_prefix', 'matchtype', 'enable_secrules', 'force_https'));
}
public function getlocationAction($uuid = null)
@@ -61,6 +61,12 @@
<style>selectpicker</style>
<help>Select an upstream to proxy to or connect via FastCGI if chosen.</help>
</field>
<field>
<id>location.path_prefix</id>
<label>Path Prefix</label>
<type>text</type>
<help>Define an optional path prefix for this location. It will be prepended to the path so http://www.example.com/index.php will be sent to http://www.example.com/app/index.php on your upstream if you choose "/app" as path prefix.</help>
</field>
<field>
<id>location.cache_path</id>
<label>Cache: Directory</label>
@@ -205,6 +205,10 @@
<Required>N</Required>
<multiple>N</multiple>
</upstream>
<path_prefix type="TextField">
<Required>N</Required>
<mask>/^[^" \t]+$/</mask>
</path_prefix>
<cache_path type="ModelRelationField">
<Model>
<template>
@@ -188,6 +188,7 @@ $( document ).ready(function() {
<tr>
<th data-column-id="description" data-type="string" data-sortable="true" data-visible="true">{{ lang._('Description') }}</th>
<th data-column-id="urlpattern" data-type="string" data-sortable="true" data-visible="true">{{ lang._('URL Pattern') }}</th>
<th data-column-id="path_prefix" data-type="string" data-sortable="true" data-visible="true">{{ lang._('URL Path Prefix') }}</th>
<th data-column-id="matchtype" data-type="string" data-sortable="true" data-visible="true">{{ lang._('Match Type') }}</th>
<th data-column-id="enable_secrules" data-type="boolean" data-sortable="true" data-visible="true">{{ lang._('WAF Enabled') }}</th>
<th data-column-id="force_https" data-type="boolean" data-sortable="true" data-visible="true">{{ lang._('Force HTTPS') }}</th>
@@ -107,8 +107,11 @@ location {{ location.matchtype }} {{ location.urlpattern }} {
proxy_cache_revalidate {% if location.cache_revalidate is defined and location.cache_revalidate == '1' %}on{% else %}off{% endif %};
proxy_cache_methods GET HEAD{% if location.cache_methods is defined and location.cache_methods != '' %} {{ location.cache_methods.replace(',', ' ') }}{% endif %};
{% endif %}
{% if location.path_prefix is defined and location.path_prefix != '' %}
proxy_pass http{% if upstream.tls_enable == '1' %}s{% endif %}://upstream{{ location.upstream.replace('-','') }}{{ location.path_prefix }};
{% else %}
proxy_pass http{% if upstream.tls_enable == '1' %}s{% endif %}://upstream{{ location.upstream.replace('-','') }};
{% endif %}
{% if upstream.tls_enable == '1' %}
{% if upstream.tls_client_certificate is defined and upstream.tls_client_certificate != '' %}
proxy_ssl_certificate_key /usr/local/etc/nginx/key/{{ upstream.tls_client_certificate }}.key;