Created
July 6, 2013 13:18
-
-
Save adamneilson/5939853 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################## | |
## ROUTE WWW TO ROOT FOR SEO | |
################################## | |
server { | |
listen 80; | |
server_name www.junkey.com; | |
# forward everything from www.junkey.com to junkey.com | |
return 301 $scheme://junkey.com$request_uri; | |
} | |
################################## | |
## DYNAMIC SUBDOMAINS | |
################################## | |
# This helped a lot: http://forum.slicehost.com/index.php?p=/discussion/1475/mass-dynamic-name-based-virtual-hosting-with-nginx/p1 | |
server { | |
listen 80; | |
server_name *.junkey.com; | |
set $domain $host; | |
if ($domain ~ "^(w{3}\.)?(.*?)\.?junkey.com") { | |
set $domain $2; | |
} | |
location / { | |
# forward everything from *.junkey.com/uri to junkey.com/*/uri | |
return 301 $scheme://junkey.com/$domain$request_uri; | |
} | |
} | |
################################## | |
## MAIN SITE | |
################################## | |
server { | |
listen 80; ## listen for ipv4; this line is default and implied | |
#listen [::]:80 default_server ipv6only=on; ## listen for ipv6 | |
root /usr/local/www; | |
index index.html; | |
# Make site accessible from junkey.com and *.junkey.com | |
server_name junkey.com; | |
################################## | |
########### CDN ROUTES ########### | |
################################## | |
# the javascript is requested by MANY clients of nhs choices website. We need to redirect to CDN. | |
location = /junkey.js { | |
return 301 $scheme://assets.junkey.com/junkey.js; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment