Skip to content

Instantly share code, notes, and snippets.

@gvarela
Created April 28, 2015 16:34
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save gvarela/6d77cdea9eeb06dc9328 to your computer and use it in GitHub Desktop.
Mimic pow and powder by generating a local nginx conf file that is symlinked to the homebrew nginx configuration. requires dnsmasq and nginx to be installed.
#!/bin/bash
rm .nginx.conf
while [[ $# > 1 ]]
do
key="$1"
case $key in
-p|--port)
PORT="$2"
shift
;;
-n|--name)
NAME="$2"
shift
;;
--public-path)
PUBLICPATH="$2"
shift
;;
*)
# unknown option
;;
esac
shift
done
if [[ -z "$PUBLICPATH" ]]
then
PUBLICPATH=`pwd`
fi
(
cat <<CONF
upstream $NAME {
server 127.0.0.1:$PORT;
}
server {
listen 80;
server_name $NAME.dev;
root $PUBLICPATH/public;
try_files \$uri/index.html \$uri.html \$uri @app;
location @app {
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header Host \$http_host;
proxy_redirect off;
proxy_pass http://$NAME;
}
}
CONF
) > .nginx.conf
ln -sf `pwd`/.nginx.conf /usr/local/etc/nginx/sites-enabled/$NAME.dev
sudo nginx -s reload
echo "Start your server on port $PORT and go to http://$NAME.dev"
@gvarela
Copy link
Author

gvarela commented Apr 28, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment