My Nginx config for local development is below.
Nginx listens to port 805 and Apache listens to port 1805.
server {
listen 805;
server_name localhost.com;
error_page 419 = @magento;
error_page 420 = @static;
location /pub/media/ {return 420;}
location /pub/static/ {return 420;}
location / {return 419;}
location @static {
root C:/work/magento/2.0/code;
access_log off;
expires max;
try_files $uri @magento;
}
location @magento {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# important for Magento
proxy_set_header Host $host:$server_port;
proxy_redirect http://localhost.com:1805/ http://localhost.com:805/;
proxy_pass http://localhost.com:1805;
}
}