Skip to content

Instantly share code, notes, and snippets.

@ahmadazimi
Forked from dylansm/nginx.conf
Created November 19, 2015 05:49
Show Gist options
  • Save ahmadazimi/abe96e70c717efb1b444 to your computer and use it in GitHub Desktop.
Save ahmadazimi/abe96e70c717efb1b444 to your computer and use it in GitHub Desktop.
Dynamic nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
access_log /usr/local/var/log/nginx/access.log;
error_log /usr/local/var/log/nginx/error.log;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 3;
gzip on;
client_max_body_size 20m;
log_format URI $uri;
#passenger_load_shell_envvars on;
passenger_root /usr/local/Cellar/passenger/5.0.6/libexec/lib/phusion_passenger/locations.ini;
server {
listen 8080;
server_name ~^(\w+)(\.dev|.+\.xip\.io|.+\.l\.izo\.me)$;
set $domain $1;
index index.html index.htm index.php;
set $root /Users/Shared/Development/Sites/$domain;
# if public dir exists set root to $project/public
if (-d /Users/Shared/Development/Sites/$domain/public) {
set $root /Users/Shared/Development/Sites/$domain/public;
}
if (-d /Users/Shared/Development/Sites/$domain/html) {
set $root /Users/Shared/Development/Sites/$domain/html;
}
if (-d /Users/Shared/Development/Sites/$domain/httpdocs) {
set $root /Users/Shared/Development/Sites/$domain/httpdocs;
}
root $root;
location ~ ^/builder(/?.*|$) {
alias /Users/Shared/Development/Sites/rhizome$1;
passenger_base_uri /;
passenger_app_root /Users/Shared/Development/Sites/rhizome;
passenger_document_root /Users/Shared/Development/Sites/rhizome/public;
passenger_ruby /Users/dylan/.rvm/gems/ruby-2.2.2@rhizome/wrappers/ruby;
passenger_enabled on;
}
# Farmer Bros Magento
# location /products {
# try_files $uri $uri/ /products/index.php?$args;
# }
location / {
#try_files $uri $uri/ /index.php?$args?; # wasn't working with Craft with trailing '?'
try_files $uri $uri/ /index.php?$args;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment