Welcome! Log In Create A New Profile

Advanced

cookie based reverse proxy?

Posted by aurora 
cookie based reverse proxy?
April 21, 2009 07:53AM
hello,

i'm currently using lighty as "reverse proxy" for delegating requests to a special host based on a cookie value. this can be done with lighty using this configuration:

...
$HTTP["cookie"] =~ "(; )?devredirect=aurora" {
proxy.server = (
"" => (("host" => "10.0.0.20", "port" => 8080))
)
}
$HTTP["cookie"] =~ "(; )?devredirect=..." {
proxy.server = (
"" => (("host" => "10.0.0.22", "port" => 8080))
)
}
...

the problem with lighty is, that mod_proxy does not currently support SSL (at least not the 1.4.x branch). now i'm looking for some other solution and would like to ask if it's possible to do such with nginx?

thanks!
Re: cookie based reverse proxy?
April 27, 2009 11:31AM
i figured it out myself -- it can be done and it's pretty easy!

[code]
server {
listen 443;
server_name ....devcenter.int;

ssl on;
ssl_certificate /etc/nginx/....crt;
ssl_certificate_key /etc/nginx/....key;

proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

location / {
if ($http_cookie ~* "(; )?devredirect=aurora") {
proxy_pass https://10.0.0.20;
break;
}
if ($http_cookie ~* "(; )?devredirect=...") {
proxy_pass https://10.0.0.22;
break;
}

...
}
}
[/code]
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 56
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready