Is there any way to redirect request to another server conf?
António P. P. Almeida
appa at perusio.net
Tue Jun 12 13:47:29 UTC 2012
On 12 Jun 2012 15h39 CEST, sunyxing at gmail.com wrote:
>> Message: 2
>> Date: Tue, 12 Jun 2012 13:40:09 +0200
>> From: Ant?nio P. P. Almeida <appa at perusio.net>
>> To: nginx-devel at nginx.org
>> Subject: Re: Is there any way to redirect request to another server
>> conf?
>> Message-ID: <87vciwg3mu.wl%appa at perusio.net>
>> Content-Type: text/plain; charset=US-ASCII
>>
>> On 12 Jun 2012 13h29 CEST, sunyxing at gmail.com wrote:
>>
>>> Hi All,
>>>
>>> I'm trying to use nginx as a proxy server which can judge server
>>> name by url.
>>>
>>> e.g.
>>>
>>> server {
>>> listen 80 default_server;
>>> my_rewrite_directive;
>>> }
>>>
>>> server {
>>> server_name a.com;
>>> root html/a;
>>> }
>>>
>>> server {
>>> server_name b.com;
>>> root html/b;
>>> }
>>>
>>> then GET /a.com/index.html will be redirected to server a.com;
>>
>> Doesn't this do what you need?
>>
>> server {
>> listen 80 default_server;
>>
>> location /a.com/index.html {
>> return 302 http://a.com$request_uri;
>> }
>>
>> location /b.com/index.html {
>> return 302 http://b.com$request_uri;
>> }
>> }
Then use Nginx as a load balancer and do consistent hashing. You can
do it in Lua or Perl.
https://github.com/chaoslawful/lua-nginx-module
https://github.com/zzzcpan/nginx-perl
AFAIK you'll need to code a new module for doing it more
specifically.
--- appa
More information about the nginx-devel
mailing list