-
Notifications
You must be signed in to change notification settings - Fork 2
/
example-site.conf
82 lines (68 loc) · 2.71 KB
/
example-site.conf
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
# redirect www.example.com to example.com
server {
listen 80;
listen 443 ssl spdy;
server_name www.example.com blog.example.com;
rewrite ^ https://example.com$request_uri? permanent;
access_log /var/log/nginx/example.com_access_log;
error_log /var/log/nginx/example.com_error_log;
}
server {
server_name example.com;
listen 80;
listen 443 default ssl spdy;
error_page 404 /404.html;
if ($ssl_protocol = "") {
rewrite ^ https://$server_name$request_uri? permanent;
}
add_header Strict-Transport-Security "max-age=31536000;";
# concatenate any intermediate certificates into one file to ensure
# the full certificate chain is sent to users
ssl_certificate /etc/nginx/ssl/startssl/example-concatenated.com.crt;
ssl_certificate_key /etc/nginx/ssl/startssl/example.com.key;
access_log /var/log/nginx/example.com_access_log;
error_log /var/log/nginx/example.com_error_log;
### This is the location on the web server where your Octopress files are
### published. Setting this here means you don't have to set it for any of the
### individual locations you define below.
root /var/www/localhost/htdocs;
### This tells Nginx to use "index.html" as the default index page everywhere
index index.html;
### This disables automatic directory index creation, since no one will be
### browsing your directories anyway
autoindex off;
### Here we define the root location...
location / {
### ...and then work some magic with "try_files", telling Nginx that for every
### request that comes in to /, it should first try to serve the URI exactly
### as it is, and if it doesn't find anything by that name to then try and
### serve the URI as a directory, and if it doesn't find a directory by that
### name to then spit out a 404 error and give up.
try_files $uri $uri/ =404;
}
### This location definition prevents Nginx from serving any files which begin
### with a dot, and further to not log any access attempts or 404s for files
### which begin with dots, to keep your access and error logs clean.
location ~ /\. {
access_log off;
log_not_found off;
deny all;
}
### This location definition prevents Nginx from serving any files which begin
### with a dollar sign, so Nginx will refuse to serve out a temp file if you
### are doing any editing inside a web-available directory
location ~ ~$ {
access_log off;
log_not_found off;
deny all;
}
### These next two locations simply prevent Nginx from logging every time the
### favicon & robots.txt files are accessed, to keep the logs clean
location = /robots.txt {
log_not_found off;
}
location = /favicon.ico {
access_log off;
log_not_found off;
}
}