nginx_vhost.conf.master 4.63 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
        if ($http_host ~* "<tmpl_var name='rewrite_domain'>$") {
Falko Timme's avatar
Falko Timme committed
28 29
            #rewrite ^/(.+)$ <tmpl_var name='rewrite_target'>$1 <tmpl_var name='rewrite_type'>;
            rewrite ^<tmpl_var name='rewrite_exclude'>/(.+)$ <tmpl_var name='rewrite_target'>$2 <tmpl_var name='rewrite_type'>;
30
        }
Falko Timme's avatar
Falko Timme committed
31
</tmpl_loop>
32 33
		
        index index.html index.htm index.php index.cgi index.pl index.xhtml;
Falko Timme's avatar
Falko Timme committed
34
		
Falko Timme's avatar
Falko Timme committed
35
<tmpl_if name='ssi' op='==' value='y'>		
Falko Timme's avatar
Falko Timme committed
36 37
        location ~ \.shtml$ {
            ssi on;
38
        }
Falko Timme's avatar
Falko Timme committed
39
</tmpl_if>
40

Falko Timme's avatar
Falko Timme committed
41
<tmpl_if name='errordocs'>		
Falko Timme's avatar
Falko Timme committed
42 43 44 45 46 47
        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;
48
        error_page 502 /error/502.html;
Falko Timme's avatar
Falko Timme committed
49
        error_page 503 /error/503.html;
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
        recursive_error_pages on;
        location = /error/400.html {
            internal;
        }
        location = /error/401.html {
            internal;
        }
        location = /error/403.html {
            internal;
        }
        location = /error/404.html {
            internal;
        }
        location = /error/405.html {
            internal;
        }
        location = /error/500.html {
            internal;
        }
        location = /error/502.html {
            internal;
        }
        location = /error/503.html {
            internal;
        }
Falko Timme's avatar
Falko Timme committed
75
</tmpl_if>
Falko Timme's avatar
Falko Timme committed
76 77
		
        error_log /var/log/ispconfig/httpd/<tmpl_var name='domain'>/error.log;
78
        access_log /var/log/ispconfig/httpd/<tmpl_var name='domain'>/access.log combined;
79

Falko Timme's avatar
Falko Timme committed
80 81 82 83 84 85 86
        ## Disable .htaccess and other hidden files
        location ~ /\. {
            deny all;
            access_log off;
            log_not_found off;
        }
		
87
        location = /favicon.ico {
Falko Timme's avatar
Falko Timme committed
88 89 90
            log_not_found off;
            access_log off;
        }
91

Falko Timme's avatar
Falko Timme committed
92 93 94 95 96 97 98 99 100 101 102
        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'>;
        }
103

104
        location ^~ /awstats-icon {
105 106 107
            alias /usr/share/awstats/icon;
        }

108
<tmpl_if name='php' op='==' value='php-fpm'>
Falko Timme's avatar
Falko Timme committed
109
        location ~ \.php$ {
110
            try_files $uri =404;
111
            include /etc/nginx/fastcgi_params;
Falko Timme's avatar
Falko Timme committed
112 113 114 115 116 117
<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
118 119 120
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_script_name;
121
            fastcgi_intercept_errors on;
Falko Timme's avatar
Falko Timme committed
122
        }
Falko Timme's avatar
Falko Timme committed
123
</tmpl_else>
Falko Timme's avatar
Falko Timme committed
124 125 126
        location ~ \.php$ {
            deny all;
        }
Falko Timme's avatar
Falko Timme committed
127
</tmpl_if>
Falko Timme's avatar
Falko Timme committed
128
		
Falko Timme's avatar
Falko Timme committed
129
<tmpl_if name='cgi' op='==' value='y'>
Falko Timme's avatar
Falko Timme committed
130
        location /cgi-bin/ {
131
            try_files $uri =404;
132
            include /etc/nginx/fastcgi_params;
Falko Timme's avatar
Falko Timme committed
133 134 135 136 137
            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;
138
            fastcgi_intercept_errors on;
139
        }
Falko Timme's avatar
Falko Timme committed
140
</tmpl_if>
Falko Timme's avatar
Falko Timme committed
141

Falko Timme's avatar
Falko Timme committed
142
<tmpl_loop name="nginx_directives">
143
        <tmpl_var name='nginx_directive'>
144 145 146
</tmpl_loop>

<tmpl_loop name="basic_auth_locations">
147
        location <tmpl_var name='htpasswd_location'> { ##merge##
148 149 150 151 152
                auth_basic "Members Only";
                auth_basic_user_file <tmpl_var name='htpasswd_path'>.htpasswd;
        }
</tmpl_loop>
	
Falko Timme's avatar
Falko Timme committed
153
}