Configuring nginx

nginx:
1. What is a cluster
in the state Unicom among multiple servers (computers), and these servers do the same thing, called clusters

2. Agent
middlemen, make the difference
in the absence of the agent when:
Moutai Distillery ---> production of a number of wine ---> sent to the customer's home / winery to buy wine directly to customers through logistics ---> suddenly there is a case customers need to eat at night (now 15:00) (clients in the Northeast) -> delayed a variety of situations
agent:
Moutai Distillery ---> start recruit agents (provincial) ---> proxy City -> when customers need to purchase Maotai only agents can buy

3. The forward proxy
scenario:
A borrow money to B -> B loaned -> A and B C found a good relationship with (A and C a very good relationship) -> A C please borrow money from B (not to mention I borrowed) -> C borrow money to find B -> B to lend money to C -> C to give money to a -> B does not know who is really to their own borrow money -> a reach their purpose
is defined:
the client sends a request to the real server, but you can not send a request to a real client for some reason, the client will find the proxy server, the request is sent to the proxy server, then the proxy server requests to the real server, the real server does not know who specifically visit my client is a (real server to see access to your proxy, not the real client)
features:
forward proxy and client are together all configurations must be on the client side, the server does not know the real truth of who the client is

4. Reverse Proxy
scenario:
someone called to a unit -> unit switchboard call -> total opportunity based on this description of the person (to find a department, a person) -> transferred to this department (the department has 5 individual) -> caller know specifically which person to answer this sector
pay bill no arrival ---> 10086/10010/10001 ---> mobile switchboard -> manual operation -> the opportunity to transfer to the total artificial -> callers who do not know the specific answer the phone -> achieved its desired outcome
definition:
the client sends a request to the server (the server is a cluster ( 4 servers)), the client does not know which server to access specific request, the client will be intercepted by the proxy server, then the proxy server sends the request to a cluster of a real server, the real server eventually result in response to the proxy server, proxy server then returns the results to the client, the client does not know the specific requests of the server is the real server or proxy server
features:
reverse proxy is a server-side and together, all configuration must On the server side, the client does not know who the real server (the client does not know his own request a proxy server or real server)

The ratio of forward proxy and reverse proxy
forward proxy and client are together, two people partnership deceive server
illegal request and reverse proxy is a server-side together, reverse proxy filtering / out of some clients
nginx reverse proxy to do when
1. To ensure the security of the entire system
2. played a role in the distribution request

Nginx reverse proxy configured on 6.linux
6.1. Review HOSTNAME
VI / etc / sysconfig / Network
6.2. HOSTNAME modifications and IP mapping
VI / etc / the hosts
6.3. Firewall Close
-Service STOP iptables
6.4. Close the firewall boot
chkconfig iptables OFF
6.5. reboot
reboot
6.6. xftp tool to use nginx archive uploaded on linux server
6.7. decompression nginx
tar -zxvf XXXXX
6.8. create a shortcut
to enter nginx directory
./configure --prefix = / usr / local / nginx-1.17. 3 (manually input, not the path on linux)
given:
./configure: error:. the the the requires the HTTP Module1 the rewrite the PCRE Library
by You the CAN Module1 disable either by the using --without-http_rewrite_module
Option, or the install the PCRE Library the INTO the system, or build the PCRE library
statically from the source with nginx by using --with-pcre = <path> option.
no nginx package must be configured on the server linux
6.9. nginx installed configuration package required
yum -y install gcc pcre-devel openssl openssl -devel
see the following installation was successful:
Dependency Updated:
cpp.x86_64 0: 0 4.4.7-23.el6 e2fsprogs.x86_64: 1.41.12-24.el6 e2fsprogs-libs.x86_64 0: 1.41.12-24. EL6
libcom_err.x86_64 0: 1.41.12-24.el6 libgcc.x86_64 0: 0 4.4.7-23.el6 libgomp.x86_64: 4.4.7-23.el6
libss.x86_64 0: 1.41.12-24.el6
Complete !
. 6.10 again create a shortcut
in nginx directory
./configure --prefix = / usr / local / nginx-1.17.3
see the following instructions to create success:
the Configuration the Summary
+ a using PCRE Library System
+ OpenSSL Library iS not Used
+ using system zlib library

nginx path prefix: "/usr/local/nginx-1.17.3"
nginx binary file: "/usr/local/nginx-1.17.3/sbin/nginx"
nginx modules path: "/usr/local/nginx-1.17.3/modules"
nginx configuration prefix: "/usr/local/nginx-1.17.3/conf"
nginx configuration file: "/usr/local/nginx-1.17.3/conf/nginx.conf"
nginx pid file: "/usr/local/nginx-1.17.3/logs/nginx.pid"
nginx error log file: "/usr/local/nginx-1.17.3/logs/error.log"
nginx http access log file: "/usr/local/nginx-1.17.3/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
HTTP SCGI the Temporary Files nginx: "scgi_temp"
. 6.11 compile nginx
also need to directory of nginx
make && make install
the following information is compiled successfully Description:
the make [1]: Leaving Directory `/home/apps/nginx-1.17.3 '
6.12. start nginx
not to unzip the package nginx directory operations
required to perform directory (/usr/local/nginx-1.17.3) shortcut
./nginx (in sbin directories)
if there is no error, indicating a successful start
6.13. use the Browse detects
192.168.1.150
see the following pages the installation was successful:
is available for purchase to nginx!
the If you see the this page, Web Server at the nginx iS successfully installed and Working Further the Configuration iS required..

For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.

Thank you for using nginx.

Reverse proxy configuration:
6.14 /usr/local/nginx-1.17.3 to be configured in the config.
Vim nginx.conf
Note:
must implement all of the configuration http {} tag inside the
upstream tomcat_server (name easily play, fun like) {
server 192.168.23.151:8080; (semicolon do not forget !!!!)
}
upstream must be disposed above the label server {}
have load order:
If the server is arranged in the following, because the final load order reason (load order from top to bottom), server load is less than the upstream, it would be an error! ! ! !
Configure server {} tag location / {} tag
the location / {} delete all content label all
LOCATION / {
proxy_pass HTTP: // tomcat_server; (upstream of the name must be consistent, otherwise it can not find the maps)
}
6.15 re nginx
need sbin directories
./nginx -s reload

6.16. Tomcat on the configuration server 151
....
6.17. Detect nginx reverse proxy configuration successful
two servers
nginx proxy server 192.168.23.150
web server (running web project) 192.168.23.151
client sends a request ---> web server ---> was blocked proxy server ---> then forwards the request to the web server by the proxy server
tomcat on nginx proxy server ip client access, access to the web page

6.18. In fact, a good reverse proxy server to ensure the security of the real, that hides the real address of the server! ! !
The client can access through a proxy server in the form of a direct request to the real server, the client was unaware

 

Guess you like

Origin www.cnblogs.com/Zs-book1/p/11433066.html