In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces how to set up reverse proxy and load balancing in nginx. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.
Reverse proxy; in fact, you can't access it or give it to nginx to return the result of the visit to the client, that is, the browser.
Let me give you another example: as we all know, it is impossible to access Google in China, so how can we access Google? We also thought, can Americans not access Google (this is nonsense, Google is American), if the IP address of the public network of our computer can be changed into the IP address of the United States, then we can access Google.
Server {listen 80; server_name localhost; # charset koi8-r; # access_log logs/host.access.log main # location / {# Note: comment out the location of the original root path. This page jumps to the home page of nginx, because two identical location paths are not allowed, otherwise an error "nginx: [emerg] duplicate location" / "in / usr/local/nginx/conf/nginx.conf:63" # root html; # index index.html index.htm will be reported. #} location / {# Root path proxy_pass http://localhost:8080; # reverse proxy}
}
Load balancing
Http {
# set the mime type, which is defined by the mime.type file
Include / etc/nginx/mime.types
Default_type application/octet-stream
# set log format
Access_log / var/log/nginx/access.log
# omit some of the configuration nodes above
# .
# set the list of servers for load balancer
Upstream mysvr {
# weigth parameter indicates the weight. The higher the weight, the greater the probability of being assigned.
Server 192.168.8.1x:3128 weight=5
# Port 3128 is enabled for Squid on this machine, but squid is not required
Server 192.168.8.2x:80 weight=1
Server 192.168.8.3x:80 weight=6
}
Upstream mysvr2 {
# weigth parameter indicates the weight. The higher the weight, the greater the probability of being assigned.
Server 192.168.8.x:80 weight=1
Server 192.168.8.x:80 weight=6
}
# the first virtual server
Server {
# listen on port 80 of 192.168.8.x
Listen 80
Server_name 192.168.8.x
# load balancing requests for aspx suffixes
Location ~. * .aspx$ {
# define the default site root location of the server
Root / root
# define the name of the index file on the home page
Index index.php index.html index.htm
# request to the list of servers defined by mysvr
Proxy_pass http://mysvr
The following are some configuration of reverse proxies that can be deleted.
Proxy_redirect off
# backend Web servers can obtain users' real IP through X-Forwarded-For
Proxy_set_header Host $host
Proxy_set_header X-Real-IP $remote_addr
Proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for
# maximum number of bytes per file that the client is allowed to request
Client_max_body_size 10m
# maximum number of bytes requested by the buffer proxy
Client_body_buffer_size 128k
# connection timeout between nginx and backend server (proxy connection timeout)
Proxy_connect_timeout 90
# response time of back-end server after successful connection (proxy received timeout)
Proxy_read_timeout 90
# set the buffer size for proxy server (nginx) to store account information
Proxy_buffer_size 4k
# proxy_buffers buffer. If the average page size is less than 32k, set it like this.
Proxy_buffers 4 32k
# buffer size under high load (proxy_buffers*2)
Proxy_busy_buffers_size 64k
# set the cache folder size. If it is larger than this value, it will be transferred from the upstream server.
Proxy_temp_file_write_size 64k
}
}
}
So much for sharing about how to set up reverse proxy and load balancer in nginx. I hope the above content can be helpful to you and learn more. If you think the article is good, you can share it for more people to see.
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.