Nginx Installation and reverse proxy test under MAC

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.