Commit f927494e authored by Falko Timme's avatar Falko Timme
Browse files

Added support for the "Redirect" tab to nginx.

parent 71279eb9
......@@ -17,6 +17,7 @@ server {
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:{fpm_port};
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
......@@ -32,6 +33,7 @@ server {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
fastcgi_pass 127.0.0.1:{fpm_port};
{ssl_comment}fastcgi_param HTTPS {fastcgi_ssl};
......
......@@ -106,7 +106,7 @@ $form["tabs"]['domain'] = array (
'datatype' => 'VARCHAR',
'formtype' => 'SELECT',
'default' => 'y',
'value' => array('' => 'no_redirect_txt', 'no' => 'no_flag_txt', 'R' => 'R', 'L' => 'L', 'R,L' => 'R,L')
'value' => array('' => 'no_redirect_txt', 'no' => 'no_flag_txt', 'R' => 'R', 'L' => 'L', 'R,L' => 'R,L', 'last' => 'last', 'break' => 'break', 'redirect' => 'redirect', 'permanent' => 'permanent')
),
'redirect_path' => array (
'datatype' => 'VARCHAR',
......
......@@ -231,7 +231,7 @@ $form["tabs"]['redirect'] = array (
'datatype' => 'VARCHAR',
'formtype' => 'SELECT',
'default' => '',
'value' => array('' => 'no_redirect_txt', 'no' => 'no_flag_txt', 'R' => 'R', 'L' => 'L', 'R,L' => 'R,L')
'value' => array('' => 'no_redirect_txt', 'no' => 'no_flag_txt', 'R' => 'R', 'L' => 'L', 'R,L' => 'R,L', 'last' => 'last', 'break' => 'break', 'redirect' => 'redirect', 'permanent' => 'permanent')
),
'redirect_path' => array (
'datatype' => 'VARCHAR',
......
......@@ -106,7 +106,7 @@ $form["tabs"]['domain'] = array (
'datatype' => 'VARCHAR',
'formtype' => 'SELECT',
'default' => 'y',
'value' => array('' => 'no_redirect_txt', 'no' => 'no_flag_txt', 'R' => 'R', 'L' => 'L', 'R,L' => 'R,L')
'value' => array('' => 'no_redirect_txt', 'no' => 'no_flag_txt', 'R' => 'R', 'L' => 'L', 'R,L' => 'R,L', 'last' => 'last', 'break' => 'break', 'redirect' => 'redirect', 'permanent' => 'permanent')
),
'redirect_path' => array (
'datatype' => 'VARCHAR',
......
......@@ -54,3 +54,34 @@
</div>
</div>
<script language="JavaScript" type="text/javascript">
var webId = jQuery('input[name="id"]').val();
var serverId;
getServerId(webId);
adjustForm(serverId);
function getServerId(webId){
jQuery.getJSON('sites/ajax_get_json.php'+ '?' + Math.round(new Date().getTime()), {web_id : webId, type : "getserverid"}, function(data) {
serverId = data.serverid;
});
}
function adjustForm(serverId){
jQuery.getJSON('sites/ajax_get_json.php'+ '?' + Math.round(new Date().getTime()), {server_id : serverId, type : "getservertype"}, function(data) {
var selected = jQuery('#redirect_type').val();
if(data.servertype == "nginx"){
jQuery('#redirect_type option[value="R"]').hide();
jQuery('#redirect_type option[value="L"]').hide();
jQuery('#redirect_type option[value="R,L"]').hide();
if(selected != "no" && selected != "" && selected != "last" && selected != "break" && selected != "redirect" && selected != "permanent") jQuery('#redirect_type option[value="no"]').attr('selected', 'selected');
} else {
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") jQuery('#redirect_type option[value="no"]').attr('selected', 'selected');
}
});
}
</script>
\ No newline at end of file
......@@ -64,17 +64,9 @@
if(data.servertype == "nginx"){
jQuery('.nginx').show();
jQuery('.apache').hide();
/*
jQuery('#allow_override').closest('div.ctrlHolder').hide();
jQuery('#apache_directives').closest('div.ctrlHolder').hide();
*/
} else {
jQuery('.nginx').hide();
jQuery('.apache').show();
/*
jQuery('#allow_override').closest('div.ctrlHolder').show();
jQuery('#apache_directives').closest('div.ctrlHolder').show();
*/
}
});
}
......
......@@ -26,3 +26,34 @@
</div>
</div>
<script language="JavaScript" type="text/javascript">
var webId = jQuery('input[name="id"]').val();
var serverId;
getServerId(webId);
adjustForm(serverId);
function getServerId(webId){
jQuery.getJSON('sites/ajax_get_json.php'+ '?' + Math.round(new Date().getTime()), {web_id : webId, type : "getserverid"}, function(data) {
serverId = data.serverid;
});
}
function adjustForm(serverId){
jQuery.getJSON('sites/ajax_get_json.php'+ '?' + Math.round(new Date().getTime()), {server_id : serverId, type : "getservertype"}, function(data) {
var selected = jQuery('#redirect_type').val();
if(data.servertype == "nginx"){
jQuery('#redirect_type option[value="R"]').hide();
jQuery('#redirect_type option[value="L"]').hide();
jQuery('#redirect_type option[value="R,L"]').hide();
if(selected != "no" && selected != "" && selected != "last" && selected != "break" && selected != "redirect" && selected != "permanent") jQuery('#redirect_type option[value="no"]').attr('selected', 'selected');
} else {
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") jQuery('#redirect_type option[value="no"]').attr('selected', 'selected');
}
});
}
</script>
\ No newline at end of file
......@@ -40,3 +40,34 @@
</div>
</div>
<script language="JavaScript" type="text/javascript">
var webId = jQuery('input[name="id"]').val();
var serverId;
getServerId(webId);
adjustForm(serverId);
function getServerId(webId){
jQuery.getJSON('sites/ajax_get_json.php'+ '?' + Math.round(new Date().getTime()), {web_id : webId, type : "getserverid"}, function(data) {
serverId = data.serverid;
});
}
function adjustForm(serverId){
jQuery.getJSON('sites/ajax_get_json.php'+ '?' + Math.round(new Date().getTime()), {server_id : serverId, type : "getservertype"}, function(data) {
var selected = jQuery('#redirect_type').val();
if(data.servertype == "nginx"){
jQuery('#redirect_type option[value="R"]').hide();
jQuery('#redirect_type option[value="L"]').hide();
jQuery('#redirect_type option[value="R,L"]').hide();
if(selected != "no" && selected != "" && selected != "last" && selected != "break" && selected != "redirect" && selected != "permanent") jQuery('#redirect_type option[value="no"]').attr('selected', 'selected');
} else {
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") jQuery('#redirect_type option[value="no"]').attr('selected', 'selected');
}
});
}
</script>
\ No newline at end of file
......@@ -10,6 +10,13 @@ server {
server_name <tmpl_var name='domain'> <tmpl_var name='alias'>;
root <tmpl_var name='web_document_root_www'>;
<tmpl_loop name="redirects">
if ($http_host ~* "<tmpl_var name='rewrite_domain'>$") {
rewrite ^/(.+)$ <tmpl_var name='rewrite_target'>$1 <tmpl_var name='rewrite_type'>;
}
</tmpl_loop>
location / {
index index.html index.php;
......@@ -47,7 +54,7 @@ server {
log_not_found off;
}
location = /favicon.ico {
location /favicon.ico {
log_not_found off;
access_log off;
}
......@@ -67,6 +74,7 @@ server {
<tmpl_if name='php' op='==' value='fast-cgi'>
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:<tmpl_var name='fpm_port'>;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
......@@ -83,6 +91,7 @@ server {
<tmpl_if name='cgi' op='==' value='y'>
location /cgi-bin/ {
try_files $uri =404;
root <tmpl_var name='document_root'>;
gzip off;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
......
......@@ -675,22 +675,24 @@ class nginx_plugin {
}
*/
$rewrite_rules[] = array( 'rewrite_domain' => $data['new']['domain'],
'rewrite_type' => ($data['new']['redirect_type'] == 'no')?'':'['.$data['new']['redirect_type'].']',
'rewrite_target' => $data['new']['redirect_path']);
switch($data['new']['subdomain']) {
case 'www':
$rewrite_rules[] = array( 'rewrite_domain' => 'www.'.$data['new']['domain'],
'rewrite_type' => ($data['new']['redirect_type'] == 'no')?'':'['.$data['new']['redirect_type'].']',
$rewrite_rules[] = array( 'rewrite_domain' => '^'.$data['new']['domain'],
'rewrite_type' => ($data['new']['redirect_type'] == 'no')?'':$data['new']['redirect_type'],
'rewrite_target' => $data['new']['redirect_path']);
$rewrite_rules[] = array( 'rewrite_domain' => '^www.'.$data['new']['domain'],
'rewrite_type' => ($data['new']['redirect_type'] == 'no')?'':$data['new']['redirect_type'],
'rewrite_target' => $data['new']['redirect_path']);
break;
case '*':
// TODO
//$rewrite_rules[] = array( 'rewrite_domain' => '*'.$alias['domain'],
// 'rewrite_type' => $alias['redirect_type'],
// 'rewrite_target' => $alias['redirect_path']);
$rewrite_rules[] = array( 'rewrite_domain' => $data['new']['domain'],
'rewrite_type' => ($data['new']['redirect_type'] == 'no')?'':$data['new']['redirect_type'],
'rewrite_target' => $data['new']['redirect_path']);
break;
default:
$rewrite_rules[] = array( 'rewrite_domain' => '^'.$data['new']['domain'],
'rewrite_type' => ($data['new']['redirect_type'] == 'no')?'':$data['new']['redirect_type'],
'rewrite_target' => $data['new']['redirect_path']);
}
}
......@@ -727,21 +729,25 @@ class nginx_plugin {
$data['new']['redirect_path'] = $data['new']['document_root'].'/web'.realpath($data['new']['redirect_path']).'/';
}
*/
$rewrite_rules[] = array( 'rewrite_domain' => $alias['domain'],
'rewrite_type' => ($alias['redirect_type'] == 'no')?'':'['.$alias['redirect_type'].']',
'rewrite_target' => $alias['redirect_path']);
switch($alias['subdomain']) {
case 'www':
$rewrite_rules[] = array( 'rewrite_domain' => 'www.'.$alias['domain'],
'rewrite_type' => ($alias['redirect_type'] == 'no')?'':'['.$alias['redirect_type'].']',
$rewrite_rules[] = array( 'rewrite_domain' => '^'.$alias['domain'],
'rewrite_type' => ($alias['redirect_type'] == 'no')?'':$alias['redirect_type'],
'rewrite_target' => $alias['redirect_path']);
$rewrite_rules[] = array( 'rewrite_domain' => '^www.'.$alias['domain'],
'rewrite_type' => ($alias['redirect_type'] == 'no')?'':$alias['redirect_type'],
'rewrite_target' => $alias['redirect_path']);
break;
case '*':
// TODO
//$rewrite_rules[] = array( 'rewrite_domain' => '*'.$alias['domain'],
// 'rewrite_type' => $alias['redirect_type'],
// 'rewrite_target' => $alias['redirect_path']);
$rewrite_rules[] = array( 'rewrite_domain' => $alias['domain'],
'rewrite_type' => ($alias['redirect_type'] == 'no')?'':$alias['redirect_type'],
'rewrite_target' => $alias['redirect_path']);
break;
default:
$rewrite_rules[] = array( 'rewrite_domain' => '^'.$alias['domain'],
'rewrite_type' => ($alias['redirect_type'] == 'no')?'':$alias['redirect_type'],
'rewrite_target' => $alias['redirect_path']);
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment