Skip to content

Commit 3c12a49

Browse files
committed
- Enabled custom nginx directives.
1 parent 5240770 commit 3c12a49

File tree

3 files changed

+22
-20
lines changed

3 files changed

+22
-20
lines changed

interface/web/sites/templates/web_domain_advanced.htm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ <h2><tmpl_var name="list_head_txt"></h2>
3232
<label for="apache_directives">{tmpl_var name='apache_directives_txt'}</label>
3333
<textarea name="apache_directives" id="apache_directives" rows='10' cols='50' style="width:400px;">{tmpl_var name='apache_directives'}</textarea>
3434
</div>
35-
<div class="ctrlHolder apache">
35+
<div class="ctrlHolder nginx">
3636
<label for="nginx_directives">{tmpl_var name='nginx_directives_txt'}</label>
3737
<textarea name="nginx_directives" id="nginx_directives" rows='10' cols='50' style="width:400px;">{tmpl_var name='nginx_directives'}</textarea>
3838
</div>

server/conf/nginx_vhost.conf.master

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ server {
2424
rewrite ^/(.+)$ <tmpl_var name='rewrite_target'>$1 <tmpl_var name='rewrite_type'>;
2525
}
2626
</tmpl_loop>
27-
28-
location / {
29-
index index.html index.php;
30-
}
27+
28+
index index.html index.htm index.php index.cgi index.pl index.xhtml;
3129

3230
<tmpl_if name='ssi' op='==' value='y'>
3331

@@ -49,19 +47,14 @@ server {
4947

5048
error_log /var/log/ispconfig/httpd/<tmpl_var name='domain'>/error.log;
5149

52-
# serve static files directly
53-
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)$ {
54-
access_log off;
55-
}
56-
5750
## Disable .htaccess and other hidden files
5851
location ~ /\. {
5952
deny all;
6053
access_log off;
6154
log_not_found off;
6255
}
6356

64-
location /favicon.ico {
57+
location = /favicon.ico {
6558
log_not_found off;
6659
access_log off;
6760
}
@@ -108,8 +101,8 @@ server {
108101
}
109102
</tmpl_if>
110103

111-
<tmpl_if name='nginx_directives'>
112-
<tmpl_var name='nginx_directives'>
113-
</tmpl_if>
104+
<tmpl_loop name="nginx_directives">
105+
<tmpl_var name='nginx_directive'>
106+
</tmpl_loop>
114107

115108
}

server/plugins-available/nginx_plugin.inc.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -639,9 +639,21 @@ function update($event_name,$data) {
639639
$vhost_data['web_document_root_www'] = $web_config['website_basedir'].'/'.$data['new']['domain'].'/web';
640640
$vhost_data['web_basedir'] = $web_config['website_basedir'];
641641
$vhost_data['ssl_domain'] = $data['new']['ssl_domain'];
642-
//$vhost_data['has_custom_php_ini'] = $has_custom_php_ini;
643-
//$vhost_data['custom_php_ini_dir'] = escapeshellcmd($custom_php_ini_dir);
644642
$vhost_data['fpm_port'] = $web_config['php_fpm_start_port'] + $data['new']['domain_id'] + 1;
643+
644+
// Custom nginx directives
645+
$final_nginx_directives = array();
646+
$nginx_directives = $data['new']['nginx_directives'];
647+
// Make sure we only have Unix linebreaks
648+
$nginx_directives = str_replace("\r\n", "\n", $nginx_directives);
649+
$nginx_directives = str_replace("\r", "\n", $nginx_directives);
650+
$nginx_directive_lines = explode("\n", $nginx_directives);
651+
if(is_array($nginx_directive_lines) && !empty($nginx_directive_lines)){
652+
foreach($nginx_directive_lines as $nginx_directive_line){
653+
$final_nginx_directives[] = array('nginx_directive' => $nginx_directive_line);
654+
}
655+
}
656+
$tpl->setLoop('nginx_directives', $final_nginx_directives);
645657

646658
// Check if a SSL cert exists
647659
$ssl_dir = $data['new']['document_root'].'/ssl';
@@ -781,11 +793,8 @@ function update($event_name,$data) {
781793
}
782794

783795
if(count($rewrite_rules) > 0) {
784-
$tpl->setVar('rewrite_enabled',1);
785-
} else {
786-
$tpl->setVar('rewrite_enabled',0);
796+
$tpl->setLoop('redirects',$rewrite_rules);
787797
}
788-
$tpl->setLoop('redirects',$rewrite_rules);
789798

790799
//* Create basic http auth for website statistics
791800
$tpl->setVar('stats_auth_passwd_file', $data['new']['document_root']."/.htpasswd_stats");

0 commit comments

Comments
 (0)