Get the App
SLTechnology News&Howtos  ›  Servers  › 

Detailed introduction of Nginx load balancing and reverse proxy

Shulou Source: shulou.com Published: 2022-06-03 07:01:39 09月21日 Update

The following brings you a detailed introduction of Nginx load balancing and reverse proxy, hoping to give you some help in practical application. Load balancing involves more things, there are not many theories, and there are many books on the Internet. Today, we use the accumulated experience in the industry to do an answer.

Nginx load balancer, reverse proxy, and then forward from the firewall, report an error, access with the public network IP+ port, as a result, the css style and port are lost! Private network IP+ port access, normal!

Solution: use chrome's network tag to analyze the path and port of the project! Kill the useless ones in the configuration file!

Personally test the modified configuration file, pay attention to the comment information!

Vi conf/nginx.confworker_processes auto;worker_rlimit_nofile 10000 worker_connections events {worker_connections 2048; multi_accept on; use epoll;} http {# include mime.types; comments are changed so that the css style can be loaded after forwarding! Default_type application/octet-stream; upstream test.com {ip_hash; server 192.1.1.100 server 192.1.1.200 server 8080;} server {listen 8888; # this is the same as the firewall external network port, otherwise the following $server_port call will be different out port, resulting in the style can not be loaded! Another reason is that both internal and external networks can be accessed! Server_name test.com; location / {proxy_pass http://test.com; proxy_set_header Host $host:$server_port; # where $server_port is the port to call listen! This line means to get the original ip and port proxy_set_header X-Real-IP $remote_addr; # after forwarding, which means to bring the original information into proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # the actual domain name address to be accessed To correspond to the actual access domain name proxy_set_header X-NginX-Proxy true;} error_page 500502503504 / 50x.html; location = / 50x.html {root html;}}

After reading the above detailed introduction of Nginx load balancing and reverse proxy, if you have anything else you need to know, you can find what you are interested in in the industry information or find our professional and technical engineer to answer, the technical engineer has more than ten years of experience in the industry.

Tags: Port equalization proxy actual style original in line industry information domain name engineering engineer technology file comment experience firewall solution configuration fire prevention Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Apple Linux NVidia Microsoft