启动nginx
brew services start nginx
关闭nginx
brew services stop nginx
重启nginx(每次改动nginx.conf文件都应该重启才能生效)
brew services restart nginx
看到截图即重启成功

nginx配置项理解
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
upstream webhost {
server 10.0.0.87:3000;
server 10.0.5.85:3000;
}
sendfile on;
keepalive_timeout 120;
server {
listen 8080;
server_name localhost;
location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 10d;
}
location ~ .*.(js|css)?$ {
expires 1h;
}
location / {
proxy_pass http://webhost;
proxy_max_temp_file_size 0;
proxy_buffering off;
}
location /api/xxx {
rewrite ^/api/(.*)$ /toproxy/api/$1 break;
proxy_pass http://webhost;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}