Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed introduction of Nginx load balancing and reverse proxy

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

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.

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report