From 11ec799aa4839a0a82fa2d51b303ff70d980d321 Mon Sep 17 00:00:00 2001
From: ftimme <ft@falkotimme.com>
Date: Wed, 07 Nov 2012 08:43:13 -0500
Subject: [PATCH] - Added Proxy Directives field for nginx if you select redirect type "proxy". - Added PayPal email address field to client and reseller form. - Added missing bank details fields to reseller form.

---
 interface/web/sites/templates/web_domain_advanced.htm          |   11 +
 interface/web/sites/templates/web_vhost_subdomain_advanced.htm |   17 +
 server/conf/nginx_vhost.conf.master                            |   10 
 interface/web/sites/web_aliasdomain_edit.php                   |   15 +
 interface/web/sites/lib/lang/en_web_vhost_subdomain.lng        |    5 
 interface/web/client/lib/lang/en_reseller.lng                  |    9 +
 interface/web/client/templates/client_edit_address.htm         |    4 
 interface/web/client/lib/lang/en_client.lng                    |    2 
 install/sql/ispconfig3.sql                                     |    2 
 interface/web/admin/form/directive_snippets.tform.php          |    2 
 interface/web/sites/templates/web_aliasdomain_advanced.htm     |   37 ++++
 server/plugins-available/nginx_plugin.inc.php                  |   42 ++++
 interface/web/sites/form/web_domain.tform.php                  |   10 +
 interface/web/sites/lib/lang/de_web_subdomain.lng              |    2 
 interface/web/sites/form/web_vhost_subdomain.tform.php         |   12 +
 interface/web/sites/web_vhost_subdomain_edit.php               |   45 +++++
 interface/web/client/form/client.tform.php                     |   23 ++
 interface/web/sites/lib/lang/de_web_domain.lng                 |    2 
 interface/web/admin/list/directive_snippets.list.php           |    2 
 interface/web/sites/ajax_get_json.php                          |    9 +
 interface/web/sites/lib/lang/en_web_domain.lng                 |    2 
 interface/web/client/lib/lang/de_reseller.lng                  |    9 +
 interface/web/sites/web_domain_edit.php                        |   10 +
 interface/web/client/lib/lang/de_client.lng                    |    4 
 interface/web/sites/lib/lang/en_web_subdomain.lng              |    2 
 install/sql/incremental/upd_0044.sql                           |    4 
 interface/web/sites/templates/web_subdomain_advanced.htm       |   37 ++++
 interface/web/sites/form/web_aliasdomain.tform.php             |   27 +++
 interface/web/sites/web_subdomain_edit.php                     |   13 +
 interface/web/sites/templates/web_vhost_subdomain_redirect.htm |    6 
 interface/web/client/form/reseller.tform.php                   |  100 +++++++++++
 interface/web/sites/form/web_subdomain.tform.php               |   27 +++
 interface/web/sites/lib/lang/de_web_vhost_subdomain.lng        |    5 
 interface/web/client/templates/reseller_edit_address.htm       |   32 +++
 34 files changed, 525 insertions(+), 14 deletions(-)

diff --git a/install/sql/incremental/upd_0044.sql b/install/sql/incremental/upd_0044.sql
new file mode 100644
index 0000000..53fe040
--- /dev/null
+++ b/install/sql/incremental/upd_0044.sql
@@ -0,0 +1,4 @@
+ALTER TABLE `client` ADD `paypal_email` VARCHAR( 255 ) NULL DEFAULT NULL AFTER `bank_account_swift` ;
+ALTER TABLE `web_domain` ADD `proxy_directives` MEDIUMTEXT NULL DEFAULT NULL ;
+
+
diff --git a/install/sql/ispconfig3.sql b/install/sql/ispconfig3.sql
index 76a13c5..64cbb39 100644
--- a/install/sql/ispconfig3.sql
+++ b/install/sql/ispconfig3.sql
@@ -166,6 +166,7 @@
   `bank_name` varchar(255) DEFAULT NULL,
   `bank_account_iban` varchar(255) DEFAULT NULL,
   `bank_account_swift` varchar(255) DEFAULT NULL,
+  `paypal_email` varchar(255) DEFAULT NULL,
   `default_mailserver` int(11) unsigned NOT NULL DEFAULT '1',
   `limit_maildomain` int(11) NOT NULL DEFAULT '-1',
   `limit_mailbox` int(11) NOT NULL DEFAULT '-1',
@@ -1750,6 +1751,7 @@
   `active` enum('n','y') NOT NULL default 'y',
   `traffic_quota_lock` enum('n','y') NOT NULL default 'n',
   `fastcgi_php_version` varchar(255) DEFAULT NULL,
+  `proxy_directives` mediumtext,
   PRIMARY KEY  (`domain_id`)
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
 
diff --git a/interface/web/admin/form/directive_snippets.tform.php b/interface/web/admin/form/directive_snippets.tform.php
index 5337084..b41e0e4 100644
--- a/interface/web/admin/form/directive_snippets.tform.php
+++ b/interface/web/admin/form/directive_snippets.tform.php
@@ -81,7 +81,7 @@
 			'datatype'	=> 'VARCHAR',
 			'formtype'	=> 'SELECT',
 			'default'	=> '',
-			'value'		=> array('apache' => 'Apache','nginx' => 'nginx','php' => 'PHP'),
+			'value'		=> array('apache' => 'Apache','nginx' => 'nginx','php' => 'PHP','proxy' => 'Proxy'),
 			'searchable' => 2
 		),
 		'snippet' => array (
diff --git a/interface/web/admin/list/directive_snippets.list.php b/interface/web/admin/list/directive_snippets.list.php
index ec023c1..593ff80 100644
--- a/interface/web/admin/list/directive_snippets.list.php
+++ b/interface/web/admin/list/directive_snippets.list.php
@@ -73,6 +73,6 @@
 							'prefix'	=> "",
 							'suffix'	=> "",
 							'width'		=> "",
-							'value'		=> array('apache' => 'Apache', 'nginx' => 'nginx', 'php' => 'PHP'));
+							'value'		=> array('apache' => 'Apache', 'nginx' => 'nginx', 'php' => 'PHP', 'proxy' => 'Proxy'));
 
 ?>
\ No newline at end of file
diff --git a/interface/web/client/form/client.tform.php b/interface/web/client/form/client.tform.php
index 1b66ac7..25623f4 100644
--- a/interface/web/client/form/client.tform.php
+++ b/interface/web/client/form/client.tform.php
@@ -431,6 +431,29 @@
 			'rows'		=> '10',
 			'cols'		=> '30'
 		),
+		'paypal_email' => array (
+			'datatype'	=> 'VARCHAR',
+			'formtype'	=> 'TEXT',
+            'filters'   => array( 0 => array( 'event' => 'SAVE',
+                                              'type' => 'IDNTOASCII'),
+                                  1 => array( 'event' => 'SHOW',
+                                              'type' => 'IDNTOUTF8'),
+                                  2 => array( 'event' => 'SAVE',
+                                              'type' => 'TOLOWER')
+                                ),
+			'validators'	=> array ( 	0 => array (	'type'	=> 'REGEX',
+														'regex' => '/^(\w+[\w\.\-\+]*\w{0,}@\w+[\w.-]*\.[a-z\-]{2,10}){0,1}$/i',
+														'errmsg'=> 'paypal_email_error_isemail'),
+									),
+			'default'	=> '',
+			'value'		=> '',
+			'separator'	=> '',
+			'width'		=> '30',
+			'maxlength'	=> '255',
+			'rows'		=> '',
+			'cols'		=> '',
+			'searchable' => 2
+		),
 	##################################
 	# END Datatable fields
 	##################################
diff --git a/interface/web/client/form/reseller.tform.php b/interface/web/client/form/reseller.tform.php
index c9079ec..b6bbe1c 100644
--- a/interface/web/client/form/reseller.tform.php
+++ b/interface/web/client/form/reseller.tform.php
@@ -340,6 +340,83 @@
 			'rows'		=> '',
 			'cols'		=> ''
 		),
+		'company_id' => array (
+			'datatype'	=> 'VARCHAR',
+			'formtype'	=> 'TEXT',
+			'default'	=> '',
+			'value'		=> '',
+			'separator'	=> '',
+			'width'		=> '30',
+			'maxlength'	=> '20',
+			'rows'		=> '',
+			'cols'		=> ''
+		),
+		'bank_account_owner' => array (
+			'datatype'	=> 'VARCHAR',
+			'formtype'	=> 'TEXT',
+			'default'	=> '',
+			'value'		=> '',
+			'separator'	=> '',
+			'width'		=> '30',
+			'maxlength'	=> '255',
+			'rows'		=> '',
+			'cols'		=> ''
+		),
+		'bank_account_number' => array (
+			'datatype'	=> 'VARCHAR',
+			'formtype'	=> 'TEXT',
+			'default'	=> '',
+			'value'		=> '',
+			'separator'	=> '',
+			'width'		=> '30',
+			'maxlength'	=> '255',
+			'rows'		=> '',
+			'cols'		=> ''
+		),
+		'bank_code' => array (
+			'datatype'	=> 'VARCHAR',
+			'formtype'	=> 'TEXT',
+			'default'	=> '',
+			'value'		=> '',
+			'separator'	=> '',
+			'width'		=> '30',
+			'maxlength'	=> '255',
+			'rows'		=> '',
+			'cols'		=> ''
+		),
+		'bank_name' => array (
+			'datatype'	=> 'VARCHAR',
+			'formtype'	=> 'TEXT',
+			'default'	=> '',
+			'value'		=> '',
+			'separator'	=> '',
+			'width'		=> '30',
+			'maxlength'	=> '255',
+			'rows'		=> '',
+			'cols'		=> ''
+		),
+		'bank_account_iban' => array (
+			'datatype'	=> 'VARCHAR',
+			'formtype'	=> 'TEXT',
+			'default'	=> '',
+			'value'		=> '',
+			'separator'	=> '',
+			'width'		=> '30',
+			'maxlength'	=> '255',
+			'rows'		=> '',
+			'cols'		=> ''
+		),
+		'bank_account_swift' => array (
+			'datatype'	=> 'VARCHAR',
+			'formtype'	=> 'TEXT',
+			'default'	=> '',
+			'value'		=> '',
+			'separator'	=> '',
+			'width'		=> '30',
+			'maxlength'	=> '255',
+			'rows'		=> '',
+			'cols'		=> ''
+		),
 		'notes' => array (
 			'datatype'	=> 'TEXT',
 			'formtype'	=> 'TEXTAREA',
@@ -351,6 +428,29 @@
 			'rows'		=> '10',
 			'cols'		=> '30'
 		),
+		'paypal_email' => array (
+			'datatype'	=> 'VARCHAR',
+			'formtype'	=> 'TEXT',
+            'filters'   => array( 0 => array( 'event' => 'SAVE',
+                                              'type' => 'IDNTOASCII'),
+                                  1 => array( 'event' => 'SHOW',
+                                              'type' => 'IDNTOUTF8'),
+                                  2 => array( 'event' => 'SAVE',
+                                              'type' => 'TOLOWER')
+                                ),
+			'validators'	=> array ( 	0 => array (	'type'	=> 'REGEX',
+														'regex' => '/^(\w+[\w\.\-\+]*\w{0,}@\w+[\w.-]*\.[a-z\-]{2,10}){0,1}$/i',
+														'errmsg'=> 'paypal_email_error_isemail'),
+									),
+			'default'	=> '',
+			'value'		=> '',
+			'separator'	=> '',
+			'width'		=> '30',
+			'maxlength'	=> '255',
+			'rows'		=> '',
+			'cols'		=> '',
+			'searchable' => 2
+		),
 	##################################
 	# END Datatable fields
 	##################################
diff --git a/interface/web/client/lib/lang/de_client.lng b/interface/web/client/lib/lang/de_client.lng
index ad9e474..4728d3e 100644
--- a/interface/web/client/lib/lang/de_client.lng
+++ b/interface/web/client/lib/lang/de_client.lng
@@ -136,5 +136,7 @@
 $wb['password_mismatch_txt'] = 'Die Passwörter stimmen nicht überein.';
 $wb['password_match_txt'] = 'Die Passwörter stimmen überein.';
 $wb['customer_no_error_unique'] = 'Die Kundennummer muß einzigartig sein (oder leer).';
-$wb['email_error_isemail'] = 'Please enter a valid email address.';
+$wb['email_error_isemail'] = 'Bitte geben Sie eine gültige Email-Adresse an.';
+$wb['paypal_email_error_isemail'] = 'Bitte geben Sie eine gültige PayPal-E-Mail-Adresse an.';
+$wb['paypal_email_txt'] = 'PayPal-E-Mail';
 ?>
diff --git a/interface/web/client/lib/lang/de_reseller.lng b/interface/web/client/lib/lang/de_reseller.lng
index cedec9d..8ee2822 100644
--- a/interface/web/client/lib/lang/de_reseller.lng
+++ b/interface/web/client/lib/lang/de_reseller.lng
@@ -130,4 +130,13 @@
 $wb['password_match_txt'] = 'Die Passwörter stimmen überein.';
 $wb['customer_no_error_unique'] = 'Die Kundennummer muß einzigartig sein (oder leer).';
 $wb['email_error_isemail'] = 'Please enter a valid email address.';
+$wb['paypal_email_error_isemail'] = 'Bitte geben Sie eine gültige PayPal-E-Mail-Adresse an.';
+$wb['paypal_email_txt'] = 'PayPal-E-Mail';
+$wb['company_id_txt'] = 'Firmen/Entrepreneur ID';
+$wb['bank_account_number_txt'] = 'Kontonummer';
+$wb['bank_account_owner_txt'] = 'Kontoinhaber';
+$wb['bank_code_txt'] = 'BLZ';
+$wb['bank_name_txt'] = 'Bank';
+$wb['bank_account_iban_txt'] = 'IBAN';
+$wb['bank_account_swift_txt'] = 'BIC';
 ?>
diff --git a/interface/web/client/lib/lang/en_client.lng b/interface/web/client/lib/lang/en_client.lng
index 1334dc4..bae3df6 100644
--- a/interface/web/client/lib/lang/en_client.lng
+++ b/interface/web/client/lib/lang/en_client.lng
@@ -140,4 +140,6 @@
 $wb['password_match_txt'] = 'The passwords do match.';
 $wb['email_error_isemail'] = 'Please enter a valid email address.';
 $wb["customer_no_error_unique"] = 'The customer no. must be unique (or empty).';
+$wb['paypal_email_error_isemail'] = 'Please enter a valid PayPal email address.';
+$wb['paypal_email_txt'] = 'PayPal Email';
 ?>
diff --git a/interface/web/client/lib/lang/en_reseller.lng b/interface/web/client/lib/lang/en_reseller.lng
index f23cd18..3d78e3c 100644
--- a/interface/web/client/lib/lang/en_reseller.lng
+++ b/interface/web/client/lib/lang/en_reseller.lng
@@ -132,4 +132,13 @@
 $wb['password_match_txt'] = 'The passwords do match.';
 $wb['email_error_isemail'] = 'Please enter a valid email address.';
 $wb["customer_no_error_unique"] = 'The customer no. must be unique (or empty).';
+$wb['paypal_email_error_isemail'] = 'Please enter a valid PayPal email address.';
+$wb['paypal_email_txt'] = 'PayPal Email';
+$wb['company_id_txt'] = 'Company/Entrepreneur ID';
+$wb["bank_account_number_txt"] = 'Bank account no.';
+$wb["bank_account_owner_txt"] = 'Bank account owner';
+$wb["bank_code_txt"] = 'Bank code';
+$wb["bank_name_txt"] = 'Bank name';
+$wb["bank_account_iban_txt"] = 'IBAN';
+$wb["bank_account_swift_txt"] = 'BIC / Swift';
 ?>
diff --git a/interface/web/client/templates/client_edit_address.htm b/interface/web/client/templates/client_edit_address.htm
index 9387944..f9d96f0 100644
--- a/interface/web/client/templates/client_edit_address.htm
+++ b/interface/web/client/templates/client_edit_address.htm
@@ -126,6 +126,10 @@
                 <label for="bank_account_swift">{tmpl_var name='bank_account_swift_txt'}</label>
                 <input name="bank_account_swift" id="bank_account_swift" value="{tmpl_var name='bank_account_swift'}" size="30" maxlength="255" type="text" class="textInput" />
             </div>
+			<div class="ctrlHolder">
+                <label for="paypal_email">{tmpl_var name='paypal_email_txt'}</label>
+                <input name="paypal_email" id="paypal_email" value="{tmpl_var name='paypal_email'}" size="30" maxlength="255" type="text" class="textInput" />
+            </div>
             <div class="ctrlHolder">
                 <label for="notes">{tmpl_var name='notes_txt'}</label>
                 <textarea name="notes" id="notes" rows='10' cols='30'>{tmpl_var name='notes'}</textarea>
diff --git a/interface/web/client/templates/reseller_edit_address.htm b/interface/web/client/templates/reseller_edit_address.htm
index ac6df07..67eabbe 100644
--- a/interface/web/client/templates/reseller_edit_address.htm
+++ b/interface/web/client/templates/reseller_edit_address.htm
@@ -98,6 +98,38 @@
                 <label for="vat_id">{tmpl_var name='vat_id_txt'}</label>
                 <input name="vat_id" id="vat_id" value="{tmpl_var name='vat_id'}" size="30" maxlength="255" type="text" class="textInput" />
             </div>
+			<div class="ctrlHolder">
+                <label for="company_id">{tmpl_var name='company_id_txt'}</label>
+                <input name="company_id" id="company_id" value="{tmpl_var name='company_id'}" size="30" maxlength="255" type="text" class="textInput" />
+            </div>
+            <div class="ctrlHolder">
+                <label for="bank_account_owner">{tmpl_var name='bank_account_owner_txt'}</label>
+                <input name="bank_account_owner" id="bank_account_owner" value="{tmpl_var name='bank_account_owner'}" size="30" maxlength="255" type="text" class="textInput" />
+            </div>
+            <div class="ctrlHolder">
+                <label for="bank_account_number">{tmpl_var name='bank_account_number_txt'}</label>
+                <input name="bank_account_number" id="bank_account_number" value="{tmpl_var name='bank_account_number'}" size="30" maxlength="255" type="text" class="textInput" />
+            </div>
+            <div class="ctrlHolder">
+                <label for="bank_code">{tmpl_var name='bank_code_txt'}</label>
+                <input name="bank_code" id="bank_code" value="{tmpl_var name='bank_code'}" size="30" maxlength="255" type="text" class="textInput" />
+            </div>
+            <div class="ctrlHolder">
+                <label for="bank_name">{tmpl_var name='bank_name_txt'}</label>
+                <input name="bank_name" id="bank_name" value="{tmpl_var name='bank_name'}" size="30" maxlength="255" type="text" class="textInput" />
+            </div>
+            <div class="ctrlHolder">
+                <label for="bank_account_iban">{tmpl_var name='bank_account_iban_txt'}</label>
+                <input name="bank_account_iban" id="bank_account_iban" value="{tmpl_var name='bank_account_iban'}" size="30" maxlength="255" type="text" class="textInput" />
+            </div>
+            <div class="ctrlHolder">
+                <label for="bank_account_swift">{tmpl_var name='bank_account_swift_txt'}</label>
+                <input name="bank_account_swift" id="bank_account_swift" value="{tmpl_var name='bank_account_swift'}" size="30" maxlength="255" type="text" class="textInput" />
+            </div>
+			<div class="ctrlHolder">
+                <label for="paypal_email">{tmpl_var name='paypal_email_txt'}</label>
+                <input name="paypal_email" id="paypal_email" value="{tmpl_var name='paypal_email'}" size="30" maxlength="255" type="text" class="textInput" />
+            </div>
             <div class="ctrlHolder">
                 <label for="notes">{tmpl_var name='notes_txt'}</label>
                 <textarea name="notes" id="notes" rows='10' cols='30'>{tmpl_var name='notes'}</textarea>
diff --git a/interface/web/sites/ajax_get_json.php b/interface/web/sites/ajax_get_json.php
index 20267eb..1194596 100644
--- a/interface/web/sites/ajax_get_json.php
+++ b/interface/web/sites/ajax_get_json.php
@@ -100,6 +100,15 @@
 		$json .= '"}';
 	}
 	
+	if($type == 'getredirecttype'){
+		$json = '{"redirecttype":"';
+		$sql = "SELECT redirect_type FROM web_domain WHERE domain_id = $web_id";
+		$redirect = $app->db->queryOneRecord($sql);
+		$json .= $redirect['redirect_type'];
+		unset($redirect);
+		$json .= '"}';
+	}
+	
 	if($type == 'get_ipv4'){		
 		$result = array();
 		
diff --git a/interface/web/sites/form/web_aliasdomain.tform.php b/interface/web/sites/form/web_aliasdomain.tform.php
index 74a7730..c7f849b 100644
--- a/interface/web/sites/form/web_aliasdomain.tform.php
+++ b/interface/web/sites/form/web_aliasdomain.tform.php
@@ -153,5 +153,32 @@
 	)
 );
 
+if($_SESSION["s"]["user"]["typ"] == 'admin') {
+
+$form["tabs"]['advanced'] = array (
+	'title' 	=> "Options",
+	'width' 	=> 100,
+	'template' 	=> "templates/web_aliasdomain_advanced.htm",
+	'readonly'	=> false,
+	'fields' 	=> array (
+	##################################
+	# Begin Datatable fields
+	##################################
+		'proxy_directives' => array (
+			'datatype'	=> 'TEXT',
+			'formtype'	=> 'TEXT',
+			'default'	=> '',
+			'value'		=> '',
+			'width'		=> '30',
+			'maxlength'	=> '255'
+		),
+	##################################
+	# ENDE Datatable fields
+	##################################
+	)
+);
+
+}
+
 
 ?>
diff --git a/interface/web/sites/form/web_domain.tform.php b/interface/web/sites/form/web_domain.tform.php
index 94eccae..45cf87e 100644
--- a/interface/web/sites/form/web_domain.tform.php
+++ b/interface/web/sites/form/web_domain.tform.php
@@ -697,7 +697,15 @@
 			'value'		=> '',
 			'width'		=> '30',
 			'maxlength'	=> '255'
-		)
+		),
+		'proxy_directives' => array (
+			'datatype'	=> 'TEXT',
+			'formtype'	=> 'TEXT',
+			'default'	=> '',
+			'value'		=> '',
+			'width'		=> '30',
+			'maxlength'	=> '255'
+		),
 	##################################
 	# ENDE Datatable fields
 	##################################
diff --git a/interface/web/sites/form/web_subdomain.tform.php b/interface/web/sites/form/web_subdomain.tform.php
index effe9f9..20c5b14 100644
--- a/interface/web/sites/form/web_subdomain.tform.php
+++ b/interface/web/sites/form/web_subdomain.tform.php
@@ -143,5 +143,32 @@
 	)
 );
 
+if($_SESSION["s"]["user"]["typ"] == 'admin') {
+
+$form["tabs"]['advanced'] = array (
+	'title' 	=> "Options",
+	'width' 	=> 100,
+	'template' 	=> "templates/web_subdomain_advanced.htm",
+	'readonly'	=> false,
+	'fields' 	=> array (
+	##################################
+	# Begin Datatable fields
+	##################################
+		'proxy_directives' => array (
+			'datatype'	=> 'TEXT',
+			'formtype'	=> 'TEXT',
+			'default'	=> '',
+			'value'		=> '',
+			'width'		=> '30',
+			'maxlength'	=> '255'
+		),
+	##################################
+	# ENDE Datatable fields
+	##################################
+	)
+);
+
+}
+
 
 ?>
diff --git a/interface/web/sites/form/web_vhost_subdomain.tform.php b/interface/web/sites/form/web_vhost_subdomain.tform.php
index f85c5f4..9899df0 100644
--- a/interface/web/sites/form/web_vhost_subdomain.tform.php
+++ b/interface/web/sites/form/web_vhost_subdomain.tform.php
@@ -291,7 +291,7 @@
 			'datatype'	=> 'VARCHAR',
 			'formtype'	=> 'SELECT',
 			'default'	=> '',
-			'value'		=> array('' => 'no_redirect_txt', 'no' => 'no_flag_txt', 'R' => 'R', 'L' => 'L', 'R,L' => 'R,L', 'R=301,L' => 'R=301,L', 'last' => 'last', 'break' => 'break', 'redirect' => 'redirect', 'permanent' => 'permanent')
+			'value'		=> array('' => 'no_redirect_txt', 'no' => 'no_flag_txt', 'R' => 'R', 'L' => 'L', 'R,L' => 'R,L', 'R=301,L' => 'R=301,L', 'last' => 'last', 'break' => 'break', 'redirect' => 'redirect', 'permanent' => 'permanent', 'proxy' => 'proxy')
 		),
 		'redirect_path' => array (
 			'datatype'	=> 'VARCHAR',
@@ -696,7 +696,15 @@
 			'value'		=> '',
 			'width'		=> '30',
 			'maxlength'	=> '255'
-		)
+		),
+		'proxy_directives' => array (
+			'datatype'	=> 'TEXT',
+			'formtype'	=> 'TEXT',
+			'default'	=> '',
+			'value'		=> '',
+			'width'		=> '30',
+			'maxlength'	=> '255'
+		),
 	##################################
 	# ENDE Datatable fields
 	##################################
diff --git a/interface/web/sites/lib/lang/de_web_domain.lng b/interface/web/sites/lib/lang/de_web_domain.lng
index 220752b..3c64f65 100644
--- a/interface/web/sites/lib/lang/de_web_domain.lng
+++ b/interface/web/sites/lib/lang/de_web_domain.lng
@@ -109,4 +109,6 @@
 $wb['available_php_directive_snippets_txt'] = 'Verfügbare PHP Direktiven Schnipsel:';
 $wb['available_apache_directive_snippets_txt'] = 'Verfügbare Apache Direktiven Schnipsel:';
 $wb['available_nginx_directive_snippets_txt'] = 'Verfügbare nginx Direktiven Schnipsel:';
+$wb['proxy_directives_txt'] = 'Proxy Direktiven';
+$wb['available_proxy_directive_snippets_txt'] = 'Verfügbare Proxy Direktiven Schnipsel:';
 ?>
diff --git a/interface/web/sites/lib/lang/de_web_subdomain.lng b/interface/web/sites/lib/lang/de_web_subdomain.lng
index 1847ba8..c956b62 100644
--- a/interface/web/sites/lib/lang/de_web_subdomain.lng
+++ b/interface/web/sites/lib/lang/de_web_subdomain.lng
@@ -40,4 +40,6 @@
 $wb['redirect_error_regex'] = 'Ungültiger redirect Pfad. Gültige Pfade sind beispielsweise: /test/ oder http://www.domain.tld/test/';
 $wb['no_redirect_txt'] = 'Kein Redirect';
 $wb['no_flag_txt'] = 'Kein Flag';
+$wb['proxy_directives_txt'] = 'Proxy Direktiven';
+$wb['available_proxy_directive_snippets_txt'] = 'Verfügbare Proxy Direktiven Schnipsel:';
 ?>
diff --git a/interface/web/sites/lib/lang/de_web_vhost_subdomain.lng b/interface/web/sites/lib/lang/de_web_vhost_subdomain.lng
index fe83bf2..e41b717 100644
--- a/interface/web/sites/lib/lang/de_web_vhost_subdomain.lng
+++ b/interface/web/sites/lib/lang/de_web_vhost_subdomain.lng
@@ -110,4 +110,9 @@
 $wb['repeat_password_txt'] = 'Passwort wiederholen';
 $wb['password_mismatch_txt'] = 'Die Passwörter stimmen nicht überein.';
 $wb['password_match_txt'] = 'Die Passwörter stimmen überein.';
+$wb['available_php_directive_snippets_txt'] = 'Verfügbare PHP Direktiven Schnipsel:';
+$wb['available_apache_directive_snippets_txt'] = 'Verfügbare Apache Direktiven Schnipsel:';
+$wb['available_nginx_directive_snippets_txt'] = 'Verfügbare nginx Direktiven Schnipsel:';
+$wb['proxy_directives_txt'] = 'Proxy Direktiven';
+$wb['available_proxy_directive_snippets_txt'] = 'Verfügbare Proxy Direktiven Schnipsel:';
 ?>
diff --git a/interface/web/sites/lib/lang/en_web_domain.lng b/interface/web/sites/lib/lang/en_web_domain.lng
index 12ed41b..5a1b651 100644
--- a/interface/web/sites/lib/lang/en_web_domain.lng
+++ b/interface/web/sites/lib/lang/en_web_domain.lng
@@ -109,4 +109,6 @@
 $wb['available_php_directive_snippets_txt'] = 'Available PHP Directive Snippets:';
 $wb['available_apache_directive_snippets_txt'] = 'Available Apache Directive Snippets:';
 $wb['available_nginx_directive_snippets_txt'] = 'Available nginx Directive Snippets:';
+$wb['proxy_directives_txt'] = 'Proxy Directives';
+$wb['available_proxy_directive_snippets_txt'] = 'Available Proxy Directive Snippets:';
 ?>
\ No newline at end of file
diff --git a/interface/web/sites/lib/lang/en_web_subdomain.lng b/interface/web/sites/lib/lang/en_web_subdomain.lng
index a6c3103..72059a4 100644
--- a/interface/web/sites/lib/lang/en_web_subdomain.lng
+++ b/interface/web/sites/lib/lang/en_web_subdomain.lng
@@ -40,4 +40,6 @@
 $wb["redirect_error_regex"] = 'Invalid redirect path. Valid redirects are for example: /test/ or http://www.domain.tld/test/';
 $wb['no_redirect_txt'] = 'No redirect';
 $wb['no_flag_txt'] = 'No flag';
+$wb['proxy_directives_txt'] = 'Proxy Directives';
+$wb['available_proxy_directive_snippets_txt'] = 'Available Proxy Directive Snippets:';
 ?>
diff --git a/interface/web/sites/lib/lang/en_web_vhost_subdomain.lng b/interface/web/sites/lib/lang/en_web_vhost_subdomain.lng
index d993af8..7ebe9e6 100644
--- a/interface/web/sites/lib/lang/en_web_vhost_subdomain.lng
+++ b/interface/web/sites/lib/lang/en_web_vhost_subdomain.lng
@@ -111,4 +111,9 @@
 $wb['repeat_password_txt'] = 'Repeat Password';
 $wb['password_mismatch_txt'] = 'The passwords do not match.';
 $wb['password_match_txt'] = 'The passwords do match.';
+$wb['available_php_directive_snippets_txt'] = 'Available PHP Directive Snippets:';
+$wb['available_apache_directive_snippets_txt'] = 'Available Apache Directive Snippets:';
+$wb['available_nginx_directive_snippets_txt'] = 'Available nginx Directive Snippets:';
+$wb['proxy_directives_txt'] = 'Proxy Directives';
+$wb['available_proxy_directive_snippets_txt'] = 'Available Proxy Directive Snippets:';
 ?>
\ No newline at end of file
diff --git a/interface/web/sites/templates/web_aliasdomain_advanced.htm b/interface/web/sites/templates/web_aliasdomain_advanced.htm
new file mode 100644
index 0000000..293b871
--- /dev/null
+++ b/interface/web/sites/templates/web_aliasdomain_advanced.htm
@@ -0,0 +1,37 @@
+<h2><tmpl_var name="list_head_txt"></h2>
+<p><tmpl_var name="list_desc_txt"></p>
+
+<div class="panel panel_web_domain">
+
+  <div class="pnl_formsarea">
+    <fieldset class="inlineLabels"><legend>Options</legend>
+      <div class="ctrlHolder proxy">
+                <label for="proxy_directives">{tmpl_var name='proxy_directives_txt'}</label>
+                <textarea name="proxy_directives" id="proxy_directives" rows='10' cols='50' style="width:400px;">{tmpl_var name='proxy_directives'}</textarea>&nbsp;<b>{tmpl_var name="available_proxy_directive_snippets_txt"}</b><br><br>&nbsp;{tmpl_var name="proxy_directive_snippets_txt"}
+            </div>
+    </fieldset>
+
+    <input type="hidden" name="id" value="{tmpl_var name='id'}">
+
+    <div class="buttonHolder buttons">
+      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onclick="submitForm('pageForm','sites/web_aliasdomain_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
+      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onclick="loadContent('sites/web_aliasdomain_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
+    </div>
+  </div>
+  
+</div>
+<script language="JavaScript" type="text/javascript">
+    var webId = jQuery('input[name="id"]').val();
+    adjustForm();
+		
+    function adjustForm(){
+		jQuery.getJSON('sites/ajax_get_json.php'+ '?' + Math.round(new Date().getTime()), {web_id : webId, type : "getredirecttype"}, function(data) {
+            if(data.redirecttype == "proxy"){
+                jQuery('.proxy').show();
+            } else {
+                jQuery('.proxy').hide();
+            }
+        });
+    }
+			
+</script>
\ No newline at end of file
diff --git a/interface/web/sites/templates/web_domain_advanced.htm b/interface/web/sites/templates/web_domain_advanced.htm
index fec38c5..f612f28 100644
--- a/interface/web/sites/templates/web_domain_advanced.htm
+++ b/interface/web/sites/templates/web_domain_advanced.htm
@@ -77,6 +77,10 @@
                 <label for="nginx_directives">{tmpl_var name='nginx_directives_txt'}</label>
                 <textarea name="nginx_directives" id="nginx_directives" rows='10' cols='50' style="width:400px;">{tmpl_var name='nginx_directives'}</textarea>&nbsp;<b>{tmpl_var name="available_nginx_directive_snippets_txt"}</b><br><br>&nbsp;{tmpl_var name="nginx_directive_snippets_txt"}
             </div>
+			<div class="ctrlHolder proxy">
+                <label for="proxy_directives">{tmpl_var name='proxy_directives_txt'}</label>
+                <textarea name="proxy_directives" id="proxy_directives" rows='10' cols='50' style="width:400px;">{tmpl_var name='proxy_directives'}</textarea>&nbsp;<b>{tmpl_var name="available_proxy_directive_snippets_txt"}</b><br><br>&nbsp;{tmpl_var name="proxy_directive_snippets_txt"}
+            </div>
         </fieldset>
 
         <input type="hidden" name="id" value="{tmpl_var name='id'}">
@@ -141,6 +145,13 @@
                 jQuery('.phpfpm').hide();
             }
         });
+		jQuery.getJSON('sites/ajax_get_json.php'+ '?' + Math.round(new Date().getTime()), {web_id : webId, type : "getredirecttype"}, function(data) {
+            if(data.redirecttype == "proxy"){
+                jQuery('.proxy').show();
+            } else {
+                jQuery('.proxy').hide();
+            }
+        });
     }
 			
 </script>
\ No newline at end of file
diff --git a/interface/web/sites/templates/web_subdomain_advanced.htm b/interface/web/sites/templates/web_subdomain_advanced.htm
new file mode 100644
index 0000000..d2beb42
--- /dev/null
+++ b/interface/web/sites/templates/web_subdomain_advanced.htm
@@ -0,0 +1,37 @@
+<h2><tmpl_var name="list_head_txt"></h2>
+<p><tmpl_var name="list_desc_txt"></p>
+
+<div class="panel panel_web_subdomain">
+
+  <div class="pnl_formsarea">
+    <fieldset class="inlineLabels"><legend>Options</legend>
+      <div class="ctrlHolder proxy">
+                <label for="proxy_directives">{tmpl_var name='proxy_directives_txt'}</label>
+                <textarea name="proxy_directives" id="proxy_directives" rows='10' cols='50' style="width:400px;">{tmpl_var name='proxy_directives'}</textarea>&nbsp;<b>{tmpl_var name="available_proxy_directive_snippets_txt"}</b><br><br>&nbsp;{tmpl_var name="proxy_directive_snippets_txt"}
+            </div>
+    </fieldset>
+
+    <input type="hidden" name="id" value="{tmpl_var name='id'}">
+
+    <div class="buttonHolder buttons">
+      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onclick="submitForm('pageForm','sites/web_subdomain_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
+      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onclick="loadContent('sites/web_subdomain_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
+    </div>
+  </div>
+  
+</div>
+<script language="JavaScript" type="text/javascript">
+    var webId = jQuery('input[name="id"]').val();
+    adjustForm();
+		
+    function adjustForm(){
+		jQuery.getJSON('sites/ajax_get_json.php'+ '?' + Math.round(new Date().getTime()), {web_id : webId, type : "getredirecttype"}, function(data) {
+            if(data.redirecttype == "proxy"){
+                jQuery('.proxy').show();
+            } else {
+                jQuery('.proxy').hide();
+            }
+        });
+    }
+			
+</script>
diff --git a/interface/web/sites/templates/web_vhost_subdomain_advanced.htm b/interface/web/sites/templates/web_vhost_subdomain_advanced.htm
index d71e30b..cffd3fa 100644
--- a/interface/web/sites/templates/web_vhost_subdomain_advanced.htm
+++ b/interface/web/sites/templates/web_vhost_subdomain_advanced.htm
@@ -67,15 +67,19 @@
             </div>
             <div class="ctrlHolder">
                 <label for="custom_php_ini">{tmpl_var name='custom_php_ini_txt'}</label>
-                <textarea name="custom_php_ini" id="custom_php_ini" rows='10' cols='50' style="width:400px;">{tmpl_var name='custom_php_ini'}</textarea>
+                <textarea name="custom_php_ini" id="custom_php_ini" rows='10' cols='50' style="width:400px;">{tmpl_var name='custom_php_ini'}</textarea>&nbsp;<b>{tmpl_var name="available_php_directive_snippets_txt"}</b><br><br>&nbsp;{tmpl_var name="php_directive_snippets_txt"}
             </div>
             <div class="ctrlHolder apache">
                 <label for="apache_directives">{tmpl_var name='apache_directives_txt'}</label>
-                <textarea name="apache_directives" id="apache_directives" rows='10' cols='50' style="width:400px;">{tmpl_var name='apache_directives'}</textarea>
+                <textarea name="apache_directives" id="apache_directives" rows='10' cols='50' style="width:400px;">{tmpl_var name='apache_directives'}</textarea>&nbsp;<b>{tmpl_var name="available_apache_directive_snippets_txt"}</b><br><br>&nbsp;{tmpl_var name="apache_directive_snippets_txt"}
             </div>
             <div class="ctrlHolder nginx">
                 <label for="nginx_directives">{tmpl_var name='nginx_directives_txt'}</label>
-                <textarea name="nginx_directives" id="nginx_directives" rows='10' cols='50' style="width:400px;">{tmpl_var name='nginx_directives'}</textarea>
+                <textarea name="nginx_directives" id="nginx_directives" rows='10' cols='50' style="width:400px;">{tmpl_var name='nginx_directives'}</textarea>&nbsp;<b>{tmpl_var name="available_nginx_directive_snippets_txt"}</b><br><br>&nbsp;{tmpl_var name="nginx_directive_snippets_txt"}
+            </div>
+			<div class="ctrlHolder proxy">
+                <label for="proxy_directives">{tmpl_var name='proxy_directives_txt'}</label>
+                <textarea name="proxy_directives" id="proxy_directives" rows='10' cols='50' style="width:400px;">{tmpl_var name='proxy_directives'}</textarea>&nbsp;<b>{tmpl_var name="available_proxy_directive_snippets_txt"}</b><br><br>&nbsp;{tmpl_var name="proxy_directive_snippets_txt"}
             </div>
         </fieldset>
 
@@ -141,6 +145,13 @@
                 jQuery('.phpfpm').hide();
             }
         });
+		jQuery.getJSON('sites/ajax_get_json.php'+ '?' + Math.round(new Date().getTime()), {web_id : webId, type : "getredirecttype"}, function(data) {
+            if(data.redirecttype == "proxy"){
+                jQuery('.proxy').show();
+            } else {
+                jQuery('.proxy').hide();
+            }
+        });
     }
 			
 </script>
\ No newline at end of file
diff --git a/interface/web/sites/templates/web_vhost_subdomain_redirect.htm b/interface/web/sites/templates/web_vhost_subdomain_redirect.htm
index ac504f1..5f44146 100644
--- a/interface/web/sites/templates/web_vhost_subdomain_redirect.htm
+++ b/interface/web/sites/templates/web_vhost_subdomain_redirect.htm
@@ -57,18 +57,20 @@
                 jQuery('#redirect_type option[value="L"]').hide();
                 jQuery('#redirect_type option[value="R,L"]').hide();
                 jQuery('#redirect_type option[value="R=301,L"]').hide();
-                if(selected != "no" && selected != "" && selected != "last"  && selected != "break"  && selected != "redirect"  && selected != "permanent") jQuery('#redirect_type option[value="no"]').attr('selected', 'selected');
+                if(selected != "no" && selected != "" && selected != "last" && selected != "break" && selected != "redirect" && selected != "permanent" && selected != "proxy") jQuery('#redirect_type option[value="no"]').attr('selected', 'selected');
             } else {
                 jQuery('#redirect_type option[value="last"]').attr('disabled','disabled');
                 jQuery('#redirect_type option[value="break"]').attr('disabled','disabled');
                 jQuery('#redirect_type option[value="redirect"]').attr('disabled','disabled');
                 jQuery('#redirect_type option[value="permanent"]').attr('disabled','disabled');
+				jQuery('#redirect_type option[value="proxy"]').attr('disabled','disabled');
 					
                 jQuery('#redirect_type option[value="last"]').hide();
                 jQuery('#redirect_type option[value="break"]').hide();
                 jQuery('#redirect_type option[value="redirect"]').hide();
                 jQuery('#redirect_type option[value="permanent"]').hide();
-                if(selected != "no" && selected != "" && selected != "R"  && selected != "L"  && selected != "R,L" && selected != "R=301,L") jQuery('#redirect_type option[value="no"]').attr('selected', 'selected');
+				jQuery('#redirect_type option[value="proxy"]').hide();
+                if(selected != "no" && selected != "" && selected != "R" && selected != "L" && selected != "R,L" && selected != "R=301,L") jQuery('#redirect_type option[value="no"]').attr('selected', 'selected');
             }
         });
     }
diff --git a/interface/web/sites/web_aliasdomain_edit.php b/interface/web/sites/web_aliasdomain_edit.php
index 6025fc9..d3315eb 100644
--- a/interface/web/sites/web_aliasdomain_edit.php
+++ b/interface/web/sites/web_aliasdomain_edit.php
@@ -112,7 +112,20 @@
 			}
 			$app->tpl->setVar("domain_option",$domain_select);
 		}
-
+		
+		if($_SESSION["s"]["user"]["typ"] == 'admin') {
+			// Directive Snippets		
+			$proxy_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'proxy' AND active = 'y'");
+			$proxy_directive_snippets_txt = '';
+			if(is_array($proxy_directive_snippets) && !empty($proxy_directive_snippets)){
+				foreach($proxy_directive_snippets as $proxy_directive_snippet){
+					$proxy_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">['.$proxy_directive_snippet['name'].']<pre class="addPlaceholderContent" style="display:none;">'.$proxy_directive_snippet['snippet'].'</pre></a> ';
+				}
+			}
+			if($proxy_directive_snippets_txt == '') $proxy_directive_snippets_txt = '------';
+			$app->tpl->setVar("proxy_directive_snippets_txt",$proxy_directive_snippets_txt);
+		}
+		
 		parent::onShowEnd();
 		
 	}
diff --git a/interface/web/sites/web_domain_edit.php b/interface/web/sites/web_domain_edit.php
index 8ac503a..758c05f 100644
--- a/interface/web/sites/web_domain_edit.php
+++ b/interface/web/sites/web_domain_edit.php
@@ -379,6 +379,16 @@
 				if($nginx_directive_snippets_txt == '') $nginx_directive_snippets_txt = '------';
 				$app->tpl->setVar("nginx_directive_snippets_txt",$nginx_directive_snippets_txt);
 			}
+			
+			$proxy_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'proxy' AND active = 'y'");
+			$proxy_directive_snippets_txt = '';
+			if(is_array($proxy_directive_snippets) && !empty($proxy_directive_snippets)){
+					foreach($proxy_directive_snippets as $proxy_directive_snippet){
+						$proxy_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">['.$proxy_directive_snippet['name'].']<pre class="addPlaceholderContent" style="display:none;">'.$proxy_directive_snippet['snippet'].'</pre></a> ';
+					}
+			}
+			if($proxy_directive_snippets_txt == '') $proxy_directive_snippets_txt = '------';
+			$app->tpl->setVar("proxy_directive_snippets_txt",$proxy_directive_snippets_txt);
 		}
 
 		$ssl_domain_select = '';
diff --git a/interface/web/sites/web_subdomain_edit.php b/interface/web/sites/web_subdomain_edit.php
index 577078b..5fb990b 100644
--- a/interface/web/sites/web_subdomain_edit.php
+++ b/interface/web/sites/web_subdomain_edit.php
@@ -120,6 +120,19 @@
         }
         $app->tpl->setVar("domain",$this->dataRecord["domain"]);
 		
+		if($_SESSION["s"]["user"]["typ"] == 'admin') {
+			// Directive Snippets		
+			$proxy_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'proxy' AND active = 'y'");
+			$proxy_directive_snippets_txt = '';
+			if(is_array($proxy_directive_snippets) && !empty($proxy_directive_snippets)){
+				foreach($proxy_directive_snippets as $proxy_directive_snippet){
+					$proxy_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">['.$proxy_directive_snippet['name'].']<pre class="addPlaceholderContent" style="display:none;">'.$proxy_directive_snippet['snippet'].'</pre></a> ';
+				}
+			}
+			if($proxy_directive_snippets_txt == '') $proxy_directive_snippets_txt = '------';
+			$app->tpl->setVar("proxy_directive_snippets_txt",$proxy_directive_snippets_txt);
+		}
+		
 		parent::onShowEnd();
 		
 	}
diff --git a/interface/web/sites/web_vhost_subdomain_edit.php b/interface/web/sites/web_vhost_subdomain_edit.php
index 56ba15d..3681cdb 100644
--- a/interface/web/sites/web_vhost_subdomain_edit.php
+++ b/interface/web/sites/web_vhost_subdomain_edit.php
@@ -197,6 +197,51 @@
 			unset($php_records);
 
             foreach($read_limits as $limit) $app->tpl->setVar($limit, ($limit == 'force_suexec' ? 'n' : 'y'));
+			
+			// Directive Snippets
+			$php_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'php' AND active = 'y'");
+			$php_directive_snippets_txt = '';
+			if(is_array($php_directive_snippets) && !empty($php_directive_snippets)){
+					foreach($php_directive_snippets as $php_directive_snippet){
+						$php_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">['.$php_directive_snippet['name'].']<pre class="addPlaceholderContent" style="display:none;">'.$php_directive_snippet['snippet'].'</pre></a> ';
+					}
+			}
+			if($php_directive_snippets_txt == '') $php_directive_snippets_txt = '------';
+			$app->tpl->setVar("php_directive_snippets_txt",$php_directive_snippets_txt);
+			
+			if($server_type == 'apache'){
+				$apache_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'apache' AND active = 'y'");
+				$apache_directive_snippets_txt = '';
+				if(is_array($apache_directive_snippets) && !empty($apache_directive_snippets)){
+						foreach($apache_directive_snippets as $apache_directive_snippet){
+							$apache_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">['.$apache_directive_snippet['name'].']<pre class="addPlaceholderContent" style="display:none;">'.$apache_directive_snippet['snippet'].'</pre></a> ';
+						}
+				}
+				if($apache_directive_snippets_txt == '') $apache_directive_snippets_txt = '------';
+				$app->tpl->setVar("apache_directive_snippets_txt",$apache_directive_snippets_txt);
+			}
+			
+			if($server_type == 'nginx'){
+				$nginx_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'nginx' AND active = 'y'");
+				$nginx_directive_snippets_txt = '';
+				if(is_array($nginx_directive_snippets) && !empty($nginx_directive_snippets)){
+						foreach($nginx_directive_snippets as $nginx_directive_snippet){
+							$nginx_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">['.$nginx_directive_snippet['name'].']<pre class="addPlaceholderContent" style="display:none;">'.$nginx_directive_snippet['snippet'].'</pre></a> ';
+						}
+				}
+				if($nginx_directive_snippets_txt == '') $nginx_directive_snippets_txt = '------';
+				$app->tpl->setVar("nginx_directive_snippets_txt",$nginx_directive_snippets_txt);
+			}
+			
+			$proxy_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'proxy' AND active = 'y'");
+			$proxy_directive_snippets_txt = '';
+			if(is_array($proxy_directive_snippets) && !empty($proxy_directive_snippets)){
+					foreach($proxy_directive_snippets as $proxy_directive_snippet){
+						$proxy_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">['.$proxy_directive_snippet['name'].']<pre class="addPlaceholderContent" style="display:none;">'.$proxy_directive_snippet['snippet'].'</pre></a> ';
+					}
+			}
+			if($proxy_directive_snippets_txt == '') $proxy_directive_snippets_txt = '------';
+			$app->tpl->setVar("proxy_directive_snippets_txt",$proxy_directive_snippets_txt);
 		}
 
 		$ssl_domain_select = '';
diff --git a/server/conf/nginx_vhost.conf.master b/server/conf/nginx_vhost.conf.master
index 5378f11..ab15542 100644
--- a/server/conf/nginx_vhost.conf.master
+++ b/server/conf/nginx_vhost.conf.master
@@ -30,7 +30,10 @@
 <tmpl_if name='use_proxy'>
 		location / {
             proxy_pass <tmpl_var name='rewrite_target'>;
-            rewrite ^/\b<tmpl_var name='rewrite_subdir'>\b(.*) $1;
+            rewrite ^/<tmpl_var name='rewrite_subdir'>/(.*) /$1;
+<tmpl_loop name="proxy_directives">
+        <tmpl_var name='proxy_directive'>
+</tmpl_loop>
         }
 </tmpl_if>
 </tmpl_loop>
@@ -197,7 +200,10 @@
 <tmpl_if name='use_proxy'>
         location / {
             proxy_pass <tmpl_var name='rewrite_target'>;
-            rewrite ^/\b<tmpl_var name='rewrite_subdir'>\b(.*) $1;
+            rewrite ^/<tmpl_var name='rewrite_subdir'>/(.*) /$1;
+<tmpl_loop name="proxy_directives">
+        <tmpl_var name='proxy_directive'>
+</tmpl_loop>
         }
 </tmpl_if>
 }
diff --git a/server/plugins-available/nginx_plugin.inc.php b/server/plugins-available/nginx_plugin.inc.php
index 365ea3b..7f88410 100644
--- a/server/plugins-available/nginx_plugin.inc.php
+++ b/server/plugins-available/nginx_plugin.inc.php
@@ -948,6 +948,23 @@
 					$data['new']['redirect_path'] = 'http'.substr($data['new']['redirect_path'],8);
 				}
 			}
+			
+			// Custom proxy directives
+			if($data['new']['redirect_type'] == 'proxy' && trim($data['new']['proxy_directives'] != '')){
+				$final_proxy_directives = array();
+				$proxy_directives = $data['new']['proxy_directives'];
+				// Make sure we only have Unix linebreaks
+				$proxy_directives = str_replace("\r\n", "\n", $proxy_directives);
+				$proxy_directives = str_replace("\r", "\n", $proxy_directives);
+				$proxy_directive_lines = explode("\n", $proxy_directives);
+				if(is_array($proxy_directive_lines) && !empty($proxy_directive_lines)){
+					foreach($proxy_directive_lines as $proxy_directive_line){
+						$final_proxy_directives[] = array('proxy_directive' => $proxy_directive_line);
+					}
+				}
+			} else {
+				$final_proxy_directives = false;
+			}
 
 			switch($data['new']['subdomain']) {
 				case 'www':
@@ -992,6 +1009,7 @@
 						'rewrite_target' 	=> $data['new']['redirect_path'],
 						'rewrite_exclude'	=> $rewrite_exclude,
 						'rewrite_subdir'	=> $rewrite_subdir,
+						'proxy_directives'	=> $final_proxy_directives,
 						'use_rewrite'	=> ($data['new']['redirect_type'] == 'proxy' ? false:true),
 						'use_proxy'	=> ($data['new']['redirect_type'] == 'proxy' ? true:false));
 					break;
@@ -1039,6 +1057,7 @@
 						'rewrite_target' 	=> $data['new']['redirect_path'],
 						'rewrite_exclude'	=> $rewrite_exclude,
 						'rewrite_subdir'	=> $rewrite_subdir,
+						'proxy_directives'	=> $final_proxy_directives,
 						'use_rewrite'	=> ($data['new']['redirect_type'] == 'proxy' ? false:true),
 						'use_proxy'	=> ($data['new']['redirect_type'] == 'proxy' ? true:false));
 					break;
@@ -1084,6 +1103,7 @@
 						'rewrite_target' 	=> $data['new']['redirect_path'],
 						'rewrite_exclude'	=> $rewrite_exclude,
 						'rewrite_subdir'	=> $rewrite_subdir,
+						'proxy_directives'	=> $final_proxy_directives,
 						'use_rewrite'	=> ($data['new']['redirect_type'] == 'proxy' ? false:true),
 						'use_proxy'	=> ($data['new']['redirect_type'] == 'proxy' ? true:false));
 			}
@@ -1120,6 +1140,24 @@
 		$aliases = $app->db->queryAllRecords('SELECT * FROM web_domain WHERE parent_domain_id = '.$data['new']['domain_id']." AND active = 'y' AND type != 'vhostsubdomain'");
 		if(is_array($aliases)) {
 			foreach($aliases as $alias) {
+			
+				// Custom proxy directives
+				if($alias['redirect_type'] == 'proxy' && trim($alias['proxy_directives'] != '')){
+					$final_proxy_directives = array();
+					$proxy_directives = $alias['proxy_directives'];
+					// Make sure we only have Unix linebreaks
+					$proxy_directives = str_replace("\r\n", "\n", $proxy_directives);
+					$proxy_directives = str_replace("\r", "\n", $proxy_directives);
+					$proxy_directive_lines = explode("\n", $proxy_directives);
+					if(is_array($proxy_directive_lines) && !empty($proxy_directive_lines)){
+						foreach($proxy_directive_lines as $proxy_directive_line){
+							$final_proxy_directives[] = array('proxy_directive' => $proxy_directive_line);
+						}
+					}
+				} else {
+					$final_proxy_directives = false;
+				}
+			
 				if($alias['redirect_type'] == '' || $alias['redirect_path'] == '') {
 					switch($alias['subdomain']) {
 						case 'www':
@@ -1169,6 +1207,7 @@
 								'rewrite_type' 		=> ($alias['redirect_type'] == 'no')?'':$alias['redirect_type'],
 								'rewrite_target' 	=> $alias['redirect_path'],
 								'rewrite_subdir'	=> $rewrite_subdir,
+								'proxy_directives'	=> $final_proxy_directives,
 								'use_rewrite'	=> ($alias['redirect_type'] == 'proxy' ? false:true),
 								'use_proxy'	=> ($alias['redirect_type'] == 'proxy' ? true:false));
 								
@@ -1194,6 +1233,7 @@
 								'rewrite_type' 		=> ($alias['redirect_type'] == 'no')?'':$alias['redirect_type'],
 								'rewrite_target' 	=> $alias['redirect_path'],
 								'rewrite_subdir'	=> $rewrite_subdir,
+								'proxy_directives'	=> $final_proxy_directives,
 								'use_rewrite'	=> ($alias['redirect_type'] == 'proxy' ? false:true),
 								'use_proxy'	=> ($alias['redirect_type'] == 'proxy' ? true:false));
 							break;
@@ -1220,6 +1260,7 @@
 								'rewrite_type' 		=> ($alias['redirect_type'] == 'no')?'':$alias['redirect_type'],
 								'rewrite_target' 	=> $alias['redirect_path'],
 								'rewrite_subdir'	=> $rewrite_subdir,
+								'proxy_directives'	=> $final_proxy_directives,
 								'use_rewrite'	=> ($alias['redirect_type'] == 'proxy' ? false:true),
 								'use_proxy'	=> ($alias['redirect_type'] == 'proxy' ? true:false));
 							break;
@@ -1248,6 +1289,7 @@
 								'rewrite_type' 		=> ($alias['redirect_type'] == 'no')?'':$alias['redirect_type'],
 								'rewrite_target' 	=> $alias['redirect_path'],
 								'rewrite_subdir'	=> $rewrite_subdir,
+								'proxy_directives'	=> $final_proxy_directives,
 								'use_rewrite'	=> ($alias['redirect_type'] == 'proxy' ? false:true),
 								'use_proxy'	=> ($alias['redirect_type'] == 'proxy' ? true:false));
 					}

--
Gitblit v1.9.1