Forum: NGINX How to rewrite with cookie

0a019cdcadce60a9d631a0968790a585?d=identicon&s=25 Rodrigo Serra Inacio (Guest)
on 2013-08-12 16:12
(Received via mailing list)
Hi, it's possible to rewrite a mobile URL using cookies?
For example, when you acess a URL with a mobile device (android) , nginx
shoul read the cookie and redirect this device according to the android
model ...

Something like this

From Samsung Galaxy GTI900 redirect to  http://mysite.com/gti900
From Samsung Tables I200 redirect to http://mysite.com/i200

It's possible ?
Thanks.
Cc3661971714a03d18eb342759829deb?d=identicon&s=25 Adie Nurahmadie (fudanchii)
on 2013-08-12 17:10
(Received via mailing list)
yes, it's possible.

The simplest way is to use if and check either $cookie_XXX or
$http_user_agent variable.
You may want to explore nginx's wiki page here
http://wiki.nginx.org/HttpCoreModule#.24cookie_COOKIE
0a019cdcadce60a9d631a0968790a585?d=identicon&s=25 Rodrigo Serra Inacio (Guest)
on 2013-08-12 20:52
(Received via mailing list)
Hi,
What do you think is more efficient...cookies or redirect by the user
agent
?

Thank you


2013/8/12 Adie Nurahmadie <nurahmadie@gmail.com>
34011bc56457235a2caa5ed1d4a29f3c?d=identicon&s=25 Jonathan Matthews (Guest)
on 2013-08-12 21:47
(Received via mailing list)
On 12 Aug 2013 19:52, "Rodrigo Serra Inacio" <roinacio@gmail.com> wrote:
>
> Hi,
> What do you think is more efficient...cookies or redirect by the user
agent ?

If you do it based on UA *at*the*network*border* you'll block mobile
users
from switching to your desktop site if they really want to. I /hate/
sites
that do that ...

J
6681550abbaf56d95d4c431382ecbd88?d=identicon&s=25 Bob S. (Guest)
on 2013-08-12 22:04
(Received via mailing list)
I agree. That is not the right way to design a website.

What about portable website development anyway?

Lean website design works for me and the websites that we design look
great
on virtually any interface. They are not gaudy though and do not feature
a
bunch of flashy details.

Lean and clean.


On Mon, Aug 12, 2013 at 3:47 PM, Jonathan Matthews
F0f89fb528a1e8bf34fccdf632a5f572?d=identicon&s=25 Jaap van Arragon (Guest)
on 2013-08-13 15:12
(Received via mailing list)
Hello,

I'am looking for a way to limit the number of connection in one hour to
a
location named /api/

I've looked at the ngx_http_limit_conn_module module but I don't
understand
how to limit the amount of connection from a specific ip address per
hour.

For example: ip address 33.33.33.33 can only make 20 connections in one
hour
to the url /api/

We use nginx as a loadbalancer/proxy.

Does somebody has a example for this?

Thanks.

Regards.
Jaap
C2008b388c5e5ff0b1787ce6730e83ae?d=identicon&s=25 Pablo J. Villarruel (Guest)
on 2013-08-13 17:54
(Received via mailing list)
Good question!


On Tue, Aug 13, 2013 at 10:12 AM, Jaap van Arragon
<j.vanarragon@lukkien.com
6681550abbaf56d95d4c431382ecbd88?d=identicon&s=25 Bob S. (Guest)
on 2013-08-13 19:24
(Received via mailing list)
One dirty way to do it would be to use a program to monitor the
connections
that access that location and then, when 20 connections in an hour have
occurred, have the config file swapped out and replaced with another
that
does not have that location block. There is a way to get Nginx to reread
it's config file without shutting it down.

Have cron restart the whole sequence again every hour. You are using
Linux/Unix I hope.

Like I said, it's a dirty but relatively easy solution.
1266aa99d1601b47bbd3ec22affbb81c?d=identicon&s=25 B.R. (Guest)
on 2013-08-13 19:40
(Received via mailing list)
Hello,

On Tue, Aug 13, 2013 at 9:12 AM, Jaap van Arragon
<j.vanarragon@lukkien.com>wrote:

> hour to the url /api/
>
> ‚ÄčLimiting connections rate sounds typically like a job that must be done
by some firewall to me...
Have you tried to look after iptables and its 'recent' module?‚Äč

We use nginx as a loadbalancer/proxy.
>
> Does somebody has a example for this?
>
> Thanks.
>
> Regards.
> Jaap
>
> ---
*B. R.*
6681550abbaf56d95d4c431382ecbd88?d=identicon&s=25 Bob S. (Guest)
on 2013-08-13 20:00
(Received via mailing list)
Maybe you should tell us what yo are trying to do in more detail. If all
you are trying to do is rate limit, there are easier ways to do it.
40b4c848b8fcd63b0cb60b9d170c3a77?d=identicon&s=25 Valentin V. Bartenev (Guest)
on 2013-08-13 21:10
(Received via mailing list)
On Tuesday 13 August 2013 17:12:11 Jaap van Arragon wrote:
>
> We use nginx as a loadbalancer/proxy.
>
> Does somebody has a example for this?
>

You can try to use the limit_req module:
http://nginx.org/en/docs/http/ngx_http_limit_req_module.html

But the minimum limit you can currently set is 1 request per minute.

  wbr, Valentin V. Bartenev

--
http://nginx.org/en/donation.html
F0f89fb528a1e8bf34fccdf632a5f572?d=identicon&s=25 Jaap van Arragon (Guest)
on 2013-08-14 13:55
(Received via mailing list)
I've tried the limit_req but the problem is that it limits the
simultaneous requests and I want to limit the total request per hour
from
one ip (not necessarily simultaneously)

We've fixed it in the application now, there seemed to be a django view
module for it.

Thanks for the options.

Regards
Jaap
40b4c848b8fcd63b0cb60b9d170c3a77?d=identicon&s=25 Valentin V. Bartenev (Guest)
on 2013-08-14 16:16
(Received via mailing list)
On Wednesday 14 August 2013 15:54:50 Jaap van Arragon wrote:
> I've tried the limit_req but the problem is that it limits the
> simultaneous requests and I want to limit the total request per hour from
> one ip (not necessarily simultaneously)

The number of simultaneous requests is limited by the *limit_conn*
module:
http://nginx.org/en/docs/http/ngx_http_limit_conn_...

But I mentioned the *limit_req* module:
http://nginx.org/en/docs/http/ngx_http_limit_req_module.html

  wbr, Valentin V. Bartenev

--
http://nginx.org/en/donation.html
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.