如何在一台静态IP上的多服务器上运行多个Web服务器

我有一个静态Ip,如1233.22.33.44,我有两个服务器有IP:服务器1:192.168.1.1服务器2:192.168.1.2

服务器1运行网站端口默认为80,我可以通过http://1233.22.33.44访问服务器1上的Web,我想在服务器2上运行Web服务器运行,我该怎么做? 感谢您的回复!

PS:对不起,我的英文。

你有多种解决scheme:负载均衡(例如keepalived)或反向代理(例如apache或nginx)。

下面是nginx作为反向代理的示例configuration:

upstream backend { ip_hash; server 192.168.1.1; server 192.168.1.2; } upstream sorry { server public_ip; } server { listen 80; ## listen for ipv4; this line is default and implied location / { error_page 502 504 = @fallback; proxy_pass http://backend; proxy_set_header Host $http_host; proxy_read_timeout 150; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location @fallback { proxy_pass http://sory; } }