/ Nginx

Setting up NGINX on Mac OSX

Heavily borrowed from: Nginx configuration for Mac OS X with Homebrew, using sites-enabled directory.

Install nginx

brew install nginx
cd /usr/local/etc/nginx/

git clone git@bitbucket.org:fountainhead/nginx-sites-available sites-available

wget "https://gist.githubusercontent.com/jimothyGator/5436538/raw/9e0b6674a6b8c50589ea4d811b845545a776ca16/default-ssl.conf"
wget "https://gist.githubusercontent.com/jimothyGator/5436538/raw/9e0b6674a6b8c50589ea4d811b845545a776ca16/default.conf"

mkdir -p /usr/local/etc/nginx/sites-enabled
cd /usr/local/etc/nginx/sites-enabled


ln -s ../sites-available/default.conf
ln -s ../sites-available/default-ssl.conf

cd /usr/local/etc/nginx/
rm nginx.conf
wget "https://gist.githubusercontent.com/jimothyGator/5436538/raw/9e0b6674a6b8c50589ea4d811b845545a776ca16/nginx.conf"

# Create log directory
sudo mkdir -p /Library/Logs/nginx/

For enabling a site:

cd /usr/local/etc/nginx/sites-enabled
ln -s ../sites-available/santoshsrinivas.dvp

Start nginx:

# Test out nginx
sudo nginx -t

sudo nginx -s stop

sudo nginx -s stop && sudo nginx

# Start nginx
sudo nginx -s reload

Update /etc/hosts file:

127.0.0.1 xeon.santoshsrinivas.dvp

My site config file:

server {
    server_name xeon.santoshsrinivas.dvp; # Replace with your domain
    access_log /var/log/xeon_ss_dvp_acc.log;
    error_log /var/log/shiny_ss_dvp_err.log;

    location / {
        proxy_pass http://127.0.0.1:9000;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_buffering off;
    }
}

My nginx.conf

#user  nobody;
worker_processes  1;

error_log  /Library/Logs/nginx/error.log;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /Library/Logs/nginx/access.log  main;

    sendfile        on;

    keepalive_timeout  65;

    index index.html index.php;
    
    upstream www-upstream-pool{
        server unix:/tmp/php-fpm.sock;
    }

    include /usr/local/etc/nginx/sites-enabled/*; 
}