In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article focuses on "Nginx installation and configuration of reverse proxy methods", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "Nginx installation and configuration of reverse proxy method" bar!
Nginx installation and reverse proxy configuration directory
Nginx download, installation
Nginx startup, restart, shutdown
Nginx configure load balancer
Nginx configure static resources
Nginx configuration reverse proxy
Nginx download, installation
Nginx download address: http://nginx.org/en/download.html decompress the folder.
Nginx startup, restart, shutdown
There are many ways to start nginx
(1) double-click nginx.exe directly, and then the black pop-up window flashes by.
(2) Open the cmd command window, change to the nginx decompression directory, enter the command nginx.exe or start nginx, and enter enter.
Check whether the startup is successful. Visit localhost with a browser. The following page indicates that the startup is successful.
You can also enter the command tasklist / fi "imagename eq nginx.exe" in the cmd command window. The following results indicate that the startup is successful.
The configuration file of nginx is nginx.conf under the conf directory. The default nginx listening port is 80. If port 80 is occupied, it can be modified to an unoccupied port.
The command to check whether port 80 is occupied is: netstat-ano | findstr 0.0.0.0 netstat 80 or netstat-ano | findstr "80" when we modify the configuration file nginx.conf of nginx, we do not need to close nginx and restart nginx, just execute the command nginx-s reload to make the changes take effect
Restart nginx
Nginx.exe-s reload
Use this command when configuration information is modified and these configurations need to be reloaded
Close nginx
If you use the cmd command window to start nginx, closing the cmd window will not end the nginx process, and you can use two methods to close nginx
(1) enter the nginx command nginx-s stop (quick stop nginx) or nginx-s quit (complete and orderly stop nginx)
(2) use taskkill taskkill / f / t / im nginx.exe
Nginx configuration reverse proxy
We can modify the nginx configuration file nginx.conf to redirect to the specified server when accessing the nginx proxy server, that is, to configure the request forwarding address through proxy_pass, that is, when we still enter http://localhost:80, the request will jump to our configured server
Similarly, we can configure multiple target servers, and when one server fails, nginx can automatically redirect requests to another server, for example, the configuration is as follows:
When the server localhost:8080 hangs, the nginxnginx automatically directs the request to the server 192.168.101.9 8080. It also adds a weight attribute, which indicates the weight of each server accessed. The higher the weight, the higher the probability of being accessed.
Nginx configure static resources
Put static resources (such as jpg | png | css | js, etc.) in the f:/nginx-1.12.2/static directory configured below, and then make the following configuration in the nginx configuration file (note: static resource configuration can only be placed in location /). You can access the 1.png images in the f:/nginx-1.12.2/static directory by accessing http://localhost:80/1.png in the browser.
Nginx configuration reverse proxy
Open the / conf/nainx.conf file and delete server {. }, or log off
Re-add server {}
Listen: the port number on which to listen
Server_name: access domain name
Location: this is configured to / directly match the project under the default ROOT under the port. The content of location is very extensive.
See: https://segmentfault.com/a/1190000009651161
Proxy_pass: the actual access address of the project
Server {listen 80; server_name tomcat1.com; # charset koi8-r; # access_log logs/host.access.log main; location / {proxy_pass http://127.0.0.1:8280; index index.html index.htm;}} server {listen 80; server_name tomcat2.com # charset koi8-r; # access_log logs/host.access.log main; location / {proxy_pass http://127.0.0.1:8281; index index.html index.htm;}} at this point, I believe you have a better understanding of "how to install and configure reverse proxy in Nginx". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.