nginx_vhost.conf.master 3.6 KB
Newer Older
1
server {
Falko Timme's avatar
Falko Timme committed
2
        listen <tmpl_var name='ip_address'>:80;
Falko Timme's avatar
Falko Timme committed
3
<tmpl_if name='ipv6_enabled'>
4
        listen [<tmpl_var name='ipv6_address'>]:80 ipv6only=on;
Falko Timme's avatar
Falko Timme committed
5
</tmpl_if>
Falko Timme's avatar
Falko Timme committed
6
		
Falko Timme's avatar
Falko Timme committed
7
<tmpl_if name='ssl_enabled'>
Falko Timme's avatar
Falko Timme committed
8
        listen <tmpl_var name='ip_address'>:443 ssl;
Falko Timme's avatar
Falko Timme committed
9
<tmpl_if name='ipv6_enabled'>
10
        listen [<tmpl_var name='ipv6_address'>]:443 ssl ipv6only=on;
Falko Timme's avatar
Falko Timme committed
11
</tmpl_if>
Falko Timme's avatar
Falko Timme committed
12 13
        ssl_certificate <tmpl_var name='document_root'>/ssl/<tmpl_var name='ssl_domain'>.crt;
        ssl_certificate_key <tmpl_var name='document_root'>/ssl/<tmpl_var name='ssl_domain'>.key;
Falko Timme's avatar
Falko Timme committed
14
</tmpl_if>
Falko Timme's avatar
Falko Timme committed
15 16
        
        server_name <tmpl_var name='domain'> <tmpl_var name='alias'>;
17

Falko Timme's avatar
Falko Timme committed
18
        root   <tmpl_var name='web_document_root_www'>;
19
		
Falko Timme's avatar
Falko Timme committed
20
<tmpl_if name='seo_redirect_enabled'>
Falko Timme's avatar
Falko Timme committed
21 22 23
        if ($http_host = "<tmpl_var name='seo_redirect_origin_domain'>") {
            rewrite ^ $scheme://<tmpl_var name='seo_redirect_target_domain'>$request_uri permanent;
        }
Falko Timme's avatar
Falko Timme committed
24
</tmpl_if>
25
		
Falko Timme's avatar
Falko Timme committed
26
<tmpl_loop name="redirects">		
27 28 29
        if ($http_host ~* "<tmpl_var name='rewrite_domain'>$") {
            rewrite ^/(.+)$ <tmpl_var name='rewrite_target'>$1 <tmpl_var name='rewrite_type'>;
        }
Falko Timme's avatar
Falko Timme committed
30
</tmpl_loop>
31 32
		
        index index.html index.htm index.php index.cgi index.pl index.xhtml;
Falko Timme's avatar
Falko Timme committed
33
		
Falko Timme's avatar
Falko Timme committed
34
<tmpl_if name='ssi' op='==' value='y'>		
Falko Timme's avatar
Falko Timme committed
35 36
        location ~ \.shtml$ {
            ssi on;
37
        }
Falko Timme's avatar
Falko Timme committed
38
</tmpl_if>
39

Falko Timme's avatar
Falko Timme committed
40
<tmpl_if name='errordocs'>		
Falko Timme's avatar
Falko Timme committed
41 42 43 44 45 46
        error_page 400 /error/400.html;
        error_page 401 /error/401.html;
        error_page 403 /error/403.html;
        error_page 404 /error/404.html;
        error_page 405 /error/405.html;
        error_page 500 /error/500.html;
47
        error_page 502 /error/502.html;
Falko Timme's avatar
Falko Timme committed
48
        error_page 503 /error/503.html;
Falko Timme's avatar
Falko Timme committed
49
</tmpl_if>
Falko Timme's avatar
Falko Timme committed
50 51
		
        error_log /var/log/ispconfig/httpd/<tmpl_var name='domain'>/error.log;
52
        access_log /var/log/ispconfig/httpd/<tmpl_var name='domain'>/access.log combined;
53

Falko Timme's avatar
Falko Timme committed
54 55 56 57 58 59 60
        ## Disable .htaccess and other hidden files
        location ~ /\. {
            deny all;
            access_log off;
            log_not_found off;
        }
		
61
        location = /favicon.ico {
Falko Timme's avatar
Falko Timme committed
62 63 64
            log_not_found off;
            access_log off;
        }
65

Falko Timme's avatar
Falko Timme committed
66 67 68 69 70 71 72 73 74 75 76
        location = /robots.txt {
            allow all;
            log_not_found off;
            access_log off;
        }
		
        location /stats {
            index index.html index.php;
            auth_basic "Members Only";
            auth_basic_user_file <tmpl_var name='stats_auth_passwd_file'>;
        }
77

Falko Timme's avatar
Falko Timme committed
78
<tmpl_if name='php' op='==' value='fast-cgi'>
Falko Timme's avatar
Falko Timme committed
79
        location ~ \.php$ {
80
            try_files $uri =404;
81
            include /etc/nginx/fastcgi_params;
Falko Timme's avatar
Falko Timme committed
82 83 84 85 86 87
<tmpl_if name='use_tcp'>
            fastcgi_pass 127.0.0.1:<tmpl_var name='fpm_port'>;
</tmpl_if>
<tmpl_if name='use_socket'>
            fastcgi_pass unix:<tmpl_var name='fpm_socket'>;
</tmpl_if>
Falko Timme's avatar
Falko Timme committed
88 89 90
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_script_name;
91
            fastcgi_intercept_errors on;
Falko Timme's avatar
Falko Timme committed
92
        }
Falko Timme's avatar
Falko Timme committed
93
</tmpl_else>
Falko Timme's avatar
Falko Timme committed
94 95 96
        location ~ \.php$ {
            deny all;
        }
Falko Timme's avatar
Falko Timme committed
97
</tmpl_if>
Falko Timme's avatar
Falko Timme committed
98
		
Falko Timme's avatar
Falko Timme committed
99
<tmpl_if name='cgi' op='==' value='y'>
Falko Timme's avatar
Falko Timme committed
100
        location /cgi-bin/ {
101
            try_files $uri =404;
102
            include /etc/nginx/fastcgi_params;
Falko Timme's avatar
Falko Timme committed
103 104 105 106 107
            root <tmpl_var name='document_root'>;
            gzip off;
            fastcgi_pass  unix:/var/run/fcgiwrap.socket;
            fastcgi_index index.cgi;
            fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
108
            fastcgi_intercept_errors on;
109
        }
Falko Timme's avatar
Falko Timme committed
110
</tmpl_if>
Falko Timme's avatar
Falko Timme committed
111

Falko Timme's avatar
Falko Timme committed
112
<tmpl_loop name="nginx_directives">
113
        <tmpl_var name='nginx_directive'>
Falko Timme's avatar
Falko Timme committed
114
</tmpl_loop>	
Falko Timme's avatar
Falko Timme committed
115
}