Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
83 lines (68 sloc) 2.71 KB
# 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;
}
}
You can’t perform that action at this time.