2011-12-30 15 views
0

現在、ロードバランシングにはNginxサーバーを使用しています。オフィスIPを特定のサーバーにリダイレクトして、他のすべてのトラフィックが正常に負荷分散されるようにしたいと考えています。Nginx負荷バランスはIPベースです

これは可能ですか?

+0

明らかであると思います – rene

答えて

0

任意のWebサーバー(Apache、Tomcat、nginxなど)で単純なリダイレクトを行うことができます。 たとえば、Javaには、次のと簡単なのindex.jspを作成することができます。

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" 
    pageEncoding="ISO-8859-1"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> 
    <title>Your Company</title> 
    <link rel="icon" type="image/png" href="http://www.yourloadbalance.com/favicon.png"> 
</head> 
<body> 
<% 
response.sendRedirect("www.yourloadbalance.com"); 
%> 
</body> 
</html> 

コードのこの作品は、ロードバランサにあなたのケースでは、指定されたURLへの各要求をリダイレクトします。

0

これが動作設定はありませんが、私は、メインのアイデアはserverfault.comで尋ねるより良い

map $remote_addr $backend { 
    default app-servers; 
    192.168.1.1 dev-servers; # office IP 
} 

upstream app-servers { # this is normal upstreams group 
    server ...; 
    server ...; 
} 

upstream dev-servers { # this is upstream(s) for Office IP 
    server ...; 
} 

server { 
    listen 80; 
    server_name bar.foo.com; 

    location/{ 
     proxy_pass http://$backend; 
    } 
}