How to rewrite with cookie

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.

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

On 12 Aug 2013 19:52, “Rodrigo Serra Inacio” [email protected] wrote:

Hi,
What do you think is more efficient…cookies or redirect by the user
agent ?

If you do it based on UA atthenetworkborder* you’ll block mobile
users
from switching to your desktop site if they really want to. I /hate/
sites
that do that …

J

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 M.

Hi,
What do you think is more efficient…cookies or redirect by the user
agent
?

Thank you

2013/8/12 Adie N. [email protected]

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

Good question!

On Tue, Aug 13, 2013 at 10:12 AM, Jaap van Arragon
<[email protected]

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.

Hello,

On Tue, Aug 13, 2013 at 9:12 AM, Jaap van Arragon
[email protected]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.

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

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.

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_module.html

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

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