Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<tmpl_loop name="vhosts">
server {
######################################################################
## Server configuration
######################################################################
# Tell nginx to listen on port <tmpl_var name='port'> (default http(s) port, IPv4)
listen <tmpl_var name='ip_address'>:<tmpl_var name='port'>;
<tmpl_if name='ipv6_enabled'>
# Tell nginx to listen on port <tmpl_var name='port'> (default http(s) port, IPv6)
listen [<tmpl_var name='ipv6_address'>]:<tmpl_var name='port'> ipv6only=on;
</tmpl_if>
server_name <tmpl_var name='domain'> <tmpl_if name='alias'><tmpl_var name='alias'></tmpl_if> <tmpl_if name='ip_address' op='!=' value='*'><tmpl_var name='ip_address'></tmpl_if>;
######################################################################
## Log configuration
######################################################################
access_log /var/log/ispconfig/httpd/<tmpl_var name='domain'>/access.log combined;
error_log /var/log/ispconfig/httpd/<tmpl_var name='domain'>/error.log;
<tmpl_if name='ssl_enabled'>
######################################################################
## SSL configuration
######################################################################
ssl on;
ssl_certificate <tmpl_var name='web_document_root_ssl'>/<tmpl_var name='ssl_domain'>.nginx.crt;
ssl_certificate_key <tmpl_var name='web_document_root_ssl'>/<tmpl_var name='ssl_domain'>.nginx.key;
</tmpl_if>
######################################################################
## Redirects configuration
######################################################################
<tmpl_if name='seo_redirect_enabled'>
# SEO Redirect
if ($http_host = "<tmpl_var name='seo_redirect_origin_domain'>") {
rewrite ^ $scheme://<tmpl_var name='seo_redirect_target_domain'>$request_uri permanent;
}
</tmpl_if>
<tmpl_if name='rewrite_enabled'>
<tmpl_loop name="redirects">
# Redirects
#if ($http_host ~* "<tmpl_var name='rewrite_domain'>$") {
# rewrite ^/(.+)$ <tmpl_var name='rewrite_target'>$1 <tmpl_var name='rewrite_type'>;
#}
</tmpl_loop>
</tmpl_if>
######################################################################
## Error configuration
######################################################################
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 502 /error/502.html;
error_page 503 /error/503.html;
######################################################################
## Locations configuration
######################################################################
location / {
# disable access log (we already have it for nginx)
access_log off;
# set the document root
root <tmpl_var name='web_document_root_www'>;
# cache apache2's answers in the cache
proxy_cache nginx_cache;
# pass all requests to apache2
<tmpl_if name='seo_redirect_enabled'>
proxy_pass http://<tmpl_if name='ip_address' op='!=' value='*'><tmpl_var name='ip_address'><tmpl_else><tmpl_var name='seo_redirect_target_domain'></tmpl_if>:<tmpl_var name='apache2_port'>;
<tmpl_else>
proxy_pass http://<tmpl_if name='ip_address' op='!=' value='*'><tmpl_var name='ip_address'><tmpl_else><tmpl_var name='domain'></tmpl_if>:<tmpl_var name='apache2_port'>;
</tmpl_if>
}
location ~ /\. {
# Don't allow any access
deny all;
# Don't log access
access_log off;
}
######################################################################
## Directives configuration
######################################################################
<tmpl_loop name="nginx_directives">
<tmpl_var name='nginx_directive'>
</tmpl_loop>
######################################################################
## CP configuration
######################################################################
# If domain.tld/ispconfig is requested, redirect to the secure ISPConfig URL
location = /ispconfig { rewrite ^ <tmpl_var name='cp_base_url'>/ permanent; }
# If domain.tld/phpmyadmin is requested, redirect to the secure phpMyAdmin URL
location = /phpmyadmin { rewrite ^ <tmpl_var name='cp_base_url'>/phpmyadmin/ permanent; }
# If domain.tld/webmail is requested, redirect to the secure RoundCube Webmail URL
location = /webmail { rewrite ^ <tmpl_var name='cp_base_url'>/webmail/ permanent; }
}
</tmpl_loop>