-
-
Save imarcelolz/6174824 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
server { | |
# we want to listen on port 80 on all IPs on our system - both IPv4 and IPv6 | |
listen [::]:80; | |
# our primary server name is the first, aliases simply come after it. you can also include wildcards like *.example.com | |
server_name blog.chrismeller.com new.chrismeller.com; | |
# where are our site files stored? | |
root /media/www/public_html/blog.chrismeller.com/public; | |
# define our access and error logs for this vhost | |
access_log /media/www/public_html/blog.chrismeller.com/logs/access.log; | |
error_log /media/www/public_html/blog.chrismeller.com/logs/error.log; | |
# very important, php won't work without this - it sets a bunch of the server | |
# values that it expects | |
include fastcgi_params; | |
# we are very simple - any requests that don't match one of the later location blocks we | |
# define will be matched by this one | |
location / { | |
# for habari, i want to redirect any requests for the admin or login pages | |
# to the ssl versions, to protect any potential sensitive input | |
rewrite ^/(admin|auth)(.*) https://$host$request_uri?; | |
# the magic. this is the equivalent of all those lines you use for mod_rewrite in Apache | |
# if the request is for "/foo", we'll first try it as a file. then as a directory. and finally | |
# we'll assume its some sort of "clean" url and hand it to index.php so our CMS can work with it | |
try_files $uri $uri/ /index.php$is_args$args; | |
# $is_args will be '?' if there is a GET string, or '' if there isn't | |
# $args is obviously then the GET string, or '' if there isn't one | |
} | |
# remember that PHP-FPM status URL we setup? we want to support it for this | |
# vhost. so if the request is for /status, hand that back to | |
# PHP using our named upstream server | |
location /status { | |
fastcgi_pass php; | |
} | |
# this is identical, but for the ping URL we setup | |
location /ping { | |
fastcgi_pass php; | |
} | |
# and finally, the magic that makes PHP work. if the file being requested ends in ".php" | |
# it's something that PHP-FPM should process, so hand it to our named upstream server | |
location ~ \.php$ { | |
fastcgi_pass php; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment