nginx_vhost.conf.master 3.35 KB
Newer Older
1
server {
Falko Timme's avatar
Falko Timme committed
2 3 4 5 6 7 8 9 10
        listen <tmpl_var name='ip_address'>:80;
		<tmpl_if name='ssl_enabled'>
		
        listen <tmpl_var name='ip_address'>:443 ssl;
        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;
		</tmpl_if>
        
        server_name <tmpl_var name='domain'> <tmpl_var name='alias'>;
11

Falko Timme's avatar
Falko Timme committed
12
        root   <tmpl_var name='web_document_root_www'>;
13
		
Falko Timme's avatar
Falko Timme committed
14 15 16 17 18 19 20
        <tmpl_if name='seo_redirect_enabled'>

        if ($http_host = "<tmpl_var name='seo_redirect_origin_domain'>") {
            rewrite ^ $scheme://<tmpl_var name='seo_redirect_target_domain'>$request_uri permanent;
        }
		</tmpl_if>
		
21 22 23 24 25 26
        <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>
27 28
		
        index index.html index.htm index.php index.cgi index.pl index.xhtml;
Falko Timme's avatar
Falko Timme committed
29 30 31 32 33
		
		<tmpl_if name='ssi' op='==' value='y'>
		
        location ~ \.shtml$ {
            ssi on;
34
        }
Falko Timme's avatar
Falko Timme committed
35
		</tmpl_if>
36

Falko Timme's avatar
Falko Timme committed
37 38 39 40 41 42 43 44 45
        <tmpl_if name='errordocs'>
		
        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;
        error_page 503 /error/503.html;
46
        </tmpl_if>
Falko Timme's avatar
Falko Timme committed
47 48
		
        error_log /var/log/ispconfig/httpd/<tmpl_var name='domain'>/error.log;
49
        access_log /var/log/ispconfig/httpd/<tmpl_var name='domain'>/access.log combined;
50

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

Falko Timme's avatar
Falko Timme committed
63 64 65 66 67 68 69 70 71 72 73
        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'>;
        }
74

Falko Timme's avatar
Falko Timme committed
75 76 77
        <tmpl_if name='php' op='==' value='fast-cgi'>
		
        location ~ \.php$ {
78
            try_files $uri =404;
79 80
            <tmpl_var name='use_tcp'>fastcgi_pass 127.0.0.1:<tmpl_var name='fpm_port'>;
            <tmpl_var name='use_socket'>fastcgi_pass unix:<tmpl_var name='fpm_socket'>;
Falko Timme's avatar
Falko Timme committed
81 82 83 84 85 86 87 88 89 90
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_script_name;
            include /etc/nginx/fastcgi_params;
        }
		</tmpl_else>
		
        location ~ \.php$ {
            deny all;
        }
91
        </tmpl_if>
Falko Timme's avatar
Falko Timme committed
92 93 94 95
		
		<tmpl_if name='cgi' op='==' value='y'>
		
        location /cgi-bin/ {
96
            try_files $uri =404;
Falko Timme's avatar
Falko Timme committed
97 98 99 100 101 102
            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;
            include /etc/nginx/fastcgi_params;
103
        }
Falko Timme's avatar
Falko Timme committed
104 105
		</tmpl_if>

106 107 108
        <tmpl_loop name="nginx_directives">
        <tmpl_var name='nginx_directive'>
        </tmpl_loop>
Falko Timme's avatar
Falko Timme committed
109 110
		
}