Installation
You can use homebrew to install Nginx directly under MAC
Brew Search Nginxbrew Install Nginx
Start Nginx:sudo nginx, access 8080 should be able to see the Welcome screen
Nginx-v View Nginx startup parameters, the configuration file location by default is
--conf-path=/usr/local/etc/nginx/nginx.conf #重新加载配置 | restart | stop | Exit nginxnginx-s reload|reopen|stop|quit The reverse proxy assumes that you want someone else to enter localhost:8080 and jump directly to localhost:2014, then Nginx.con F in the configuration
HTTP { server { listen 8080; Location/{ proxy_pass http://127.0.0.1:2014;}} }
Load Balancer Plus Reverse proxy
MyApp1 is a collection of Web pages, here as a variable
HTTP { Upstream MyApp1 { server srv1.example.com; Server srv2.example.com; Server srv3.example.com; } server { listen 8080; Location/{ proxy_pass http://myapp1;}} }
Attention:
1. The thing behind the location is a URI address, or the request of the root directory to jump directly to the MYAPP1, of course, the URI can be longer, such as/name, such as the specific how to replace the Proxy_pass to deal with, here are divided into two situations
If proxy_pass
the directive is specified with a URI and then when a request was passed to the server and the part of a normalized req Uest URI matching the location was replaced by a URIs specified in the directive:
location/name/{ proxy_pass http://127.0.0.1/remote/;}
If proxy_pass
is specified without a URI, the request URI was passed to the server in the same form as sent by a client when the Original request is a processed, or the full normalized request URI was passed when processing the changed URI:
location/some/path/{ proxy_pass http://127.0.0.1;}
Reference
1. Http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass
2. https://www.nginx.com/blog/load-balancing-with-nginx-plus-part2/?_ga=1.269115441.1947437472.1438069067
Nginx Installation and reverse proxy test under MAC