Too many redirects

2017-09-14 Thread tseveendorj

Hi,
I configured http (www, non-www) to https (non-www) and https (www) to 
https (non-www). It is working fine. But I need to add geoip redirection 
in location / but I got Too many redirect.


This server is behind load balancer. LB is redirecting 80 to 81 and 443 
to 80.

server {
listen  81;
server_name www.example.com example.com;
return  301 https://example.com$request_uri;
}
server {
listen  80;
server_name www.example.com;
return  301 https://example.com$request_uri;
}
server {
listen   80; ## listen for ipv4; this line is default and implied
server_name example.com;

...
}

I added geoip redirection in

nginx.conf
geoip_country /usr/share/GeoIP/GeoIP.dat;

sites-enabled/example.com

location / {

# AWS load balancer access log off
if ($ignore_ua) {
access_log off;
return 200;
}

index index.html;
if ($geoip_country_code != "JP") { return 301 
https://example.com/en/; }

}
location = /en/ {
index index.html;
try_files $uri $uri/ =404;
}

I'm trying to if request from other than JP request go to /en/ if not 
/index.html


BR,
Tseveen





___
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx


rewrite difficulty

2013-04-29 Thread tseveendorj

Hello,

I have difficulty to convert apache like rewrite to nginx. This is my 
config file of virtualhost on nginx. http://pastebin.com/HTtKXnFy


My installed php script should have following rewrite 
http://pastebin.com/M2h3uAt3


Currently any requested php code displayed it's source on browser. How 
could I migrate ?


Thanks.


___
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Rewrite

2016-04-05 Thread tseveendorj

Hello,

I cannot do following

request URL is http://domain.com/x4Zbs5B
It should be http://domain.com/index.php?download=x4Zbs5B

I tried
location / {
rewrite ^/([^/][a-zA-Z0-9]+)$ /index.php?download=$1 break;
try_files $uri $uri/ /index.php?download=$uri;
}
but it is downloading index.php file itself :D

how to on nginx ?


___
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx


Re: Rewrite

2016-04-06 Thread tseveendorj


Thank you Francis. It is working now.


Sent from my Samsung device

 Original message 
From: Francis Daly  
Date: 06/04/2016  07:48  (GMT+08:00) 
To: nginx@nginx.org 
Subject: Re: Rewrite 

On Tue, Apr 05, 2016 at 08:11:44PM +0900, tseveendorj wrote:

Hi there,

> request URL is http://domain.com/x4Zbs5B
> It should be http://domain.com/index.php?download=x4Zbs5B
> 
> I tried
> location / {
> rewrite ^/([^/][a-zA-Z0-9]+)$ /index.php?download=$1 break;

I'm not sure that the four characters "[^/]" are doing anything useful
on that line.

I am sure that "break" is not what you want there. Just remove it.

> try_files $uri $uri/ /index.php?download=$uri;
> }
> but it is downloading index.php file itself :D

Presumably somewhere else in your config you tell nginx how to handle
/index.php?

f
-- 
Francis Daly    fran...@daoine.org

___
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
___
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Run time php variable change

2016-09-14 Thread Tseveendorj Ochirlantuu
Hello,

I try to explain what I want to do. I have website which is needed php
max_execution_time should be different on action.

default max_execution_time = 30 seconds

but I need to increase execution time 60 seconds on some location or action

http://example.com/request

Is it possible to do that on nginx to php-fpm ?

Regards
___
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Re: Run time php variable change

2016-09-15 Thread Tseveendorj Ochirlantuu
Hello,

Basti thank you for help.

Does this override system wide or it applied to /foo location ?

Best regards,
Tseveen

On Thu, Sep 15, 2016 at 4:20 PM, basti  wrote:

> Hello,
>
> you can use "fastcgi_param PHP_VALUE" to change PHP values.
>
> For example:
>
> location /foo {
>
>location ~ ^(.*.\.php)(.*)$ {
>   fastcgi_buffers 4 256k;
>   fastcgi_buffer_size 128k;
>   fastcgi_param PHP_VALUE "max_execution_time = 60";
>}
> }
>
> Best Regards,
> Basti
>
>
> On 15.09.2016 02:41, Tseveendorj Ochirlantuu wrote:
> > Hello,
> >
> > I try to explain what I want to do. I have website which is needed php
> > max_execution_time should be different on action.
> >
> > default max_execution_time = 30 seconds
> >
> > but I need to increase execution time 60 seconds on some location or
> action
> >
> > http://example.com/request
> >
> > Is it possible to do that on nginx to php-fpm ?
> >
> > Regards
> >
> >
> > ___
> > nginx mailing list
> > nginx@nginx.org
> > http://mailman.nginx.org/mailman/listinfo/nginx
> >
>
> ___
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
___
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Re: Run time php variable change

2016-09-15 Thread Tseveendorj Ochirlantuu
Great. Thank you.

On Thu, Sep 15, 2016 at 4:45 PM, basti  wrote:

> It should work per location. I have nothing found in the docs at the
> moment.
> But be warned if you use more than one value here you must do something
> like
>
> fastcgi_param  PHP_VALUE "register_globals=0
> display_errors=0";
>
> or
>
> fastcgi_param  PHP_VALUE "register_globals=0\ndisplay_errors=0";
>
> On 15.09.2016 09:26, Tseveendorj Ochirlantuu wrote:
> > Hello,
> >
> > Basti thank you for help.
> >
> > Does this override system wide or it applied to /foo location ?
> >
> > Best regards,
> > Tseveen
> >
> > On Thu, Sep 15, 2016 at 4:20 PM, basti  > <mailto:black.flederm...@arcor.de>> wrote:
> >
> > Hello,
> >
> > you can use "fastcgi_param PHP_VALUE" to change PHP values.
> >
> > For example:
> >
> > location /foo {
> >
> >location ~ ^(.*.\.php)(.*)$ {
> >   fastcgi_buffers 4 256k;
> >   fastcgi_buffer_size 128k;
> >   fastcgi_param PHP_VALUE "max_execution_time = 60";
> >}
> > }
> >
> > Best Regards,
> > Basti
> >
> >
> > On 15.09.2016 02:41, Tseveendorj Ochirlantuu wrote:
> > > Hello,
> > >
> > > I try to explain what I want to do. I have website which is needed
> php
> > > max_execution_time should be different on action.
> > >
> > > default max_execution_time = 30 seconds
> > >
> > > but I need to increase execution time 60 seconds on some location
> > or action
> > >
> > > http://example.com/request
> > >
> > > Is it possible to do that on nginx to php-fpm ?
> > >
> > > Regards
> > >
> > >
> > > ___
> > > nginx mailing list
> > > nginx@nginx.org <mailto:nginx@nginx.org>
> > > http://mailman.nginx.org/mailman/listinfo/nginx
> > <http://mailman.nginx.org/mailman/listinfo/nginx>
> > >
> >
> > ___
> > nginx mailing list
> > nginx@nginx.org <mailto:nginx@nginx.org>
> > http://mailman.nginx.org/mailman/listinfo/nginx
> > <http://mailman.nginx.org/mailman/listinfo/nginx>
> >
> >
> >
> >
> > ___
> > nginx mailing list
> > nginx@nginx.org
> > http://mailman.nginx.org/mailman/listinfo/nginx
> >
>
> ___
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
___
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

specific to index.php rest of them index.html

2016-10-03 Thread Tseveendorj Ochirlantuu
Hello,

I need to configure some locations go to index.php rest go to index.html


if ($request_uri !~ ^/(location1|location2|location3)$ ) {
  rewrite ^(.*) /index.html;
}

but how to else ?

if the request contains location1, location2, location3 goes to
fastcgi_pass 127.0.0.1:9000;
if not contain go to /index.html

regards,
tseveen
___
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Re: specific to index.php rest of them index.html

2016-10-03 Thread Tseveendorj Ochirlantuu
This is for symfony2 project.

location ~ /location1 {
  fastcgi things;
}

location ~ /location2 {
  fastcgi things;
}

location ~ /location3 {
  fastcgi things;
}


location / {
  index index.html;
}

Above examples how fit to symfony2 below. Mine is


# dev
location ~ ^(app_dev|config)\.php$ {
  fastcgi things;
}

# prod
location ~ ^app.php {
  fastcgi things;
}

location ~ \.php {
 deny all;
}

location / {
  try_files;
}

On Mon, Oct 3, 2016 at 8:40 PM, Richard Stanway 
wrote:

> Why not use the location directive? This is what it is designed for.
>
> http://nginx.org/en/docs/http/ngx_http_core_module.html#location
>
>
> On Mon, Oct 3, 2016 at 12:28 PM, Tseveendorj Ochirlantuu <
> tseveend...@gmail.com> wrote:
>
>> Hello,
>>
>> I need to configure some locations go to index.php rest go to index.html
>>
>>
>> if ($request_uri !~ ^/(location1|location2|location3)$ ) {
>>   rewrite ^(.*) /index.html;
>> }
>>
>> but how to else ?
>>
>> if the request contains location1, location2, location3 goes to
>> fastcgi_pass 127.0.0.1:9000;
>> if not contain go to /index.html
>>
>> regards,
>> tseveen
>>
>> ___
>> nginx mailing list
>> nginx@nginx.org
>> http://mailman.nginx.org/mailman/listinfo/nginx
>>
>
>
> ___
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
___
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

exclude error_page on geoip

2016-11-02 Thread Tseveendorj Ochirlantuu
Hello,

I need to use geoip module for allow specific region access to my website.
But blocked users should see the error_page. Users are blocked and cannot
see custom error_page.

I don't want to see error_page from other domain. I need to except only
error page which is not applied to geoip block.

How do this

BR,
Tseveen
___
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Re: exclude error_page on geoip

2016-11-04 Thread Tseveendorj Ochirlantuu
Thank you very much. It is working :)

On Thu, Nov 3, 2016 at 9:18 PM, Maxim Dounin  wrote:

> Hello!
>
> On Thu, Nov 03, 2016 at 02:05:55PM +0800, Tseveendorj Ochirlantuu wrote:
>
> > Hello,
> >
> > I need to use geoip module for allow specific region access to my
> website.
> > But blocked users should see the error_page. Users are blocked and cannot
> > see custom error_page.
> >
> > I don't want to see error_page from other domain. I need to except only
> > error page which is not applied to geoip block.
>
> Try something like this:
>
> server {
> listen 80;
>
> error_page 403 /403.html;
>
> location / {
> if ($blocked) {
> return 403;
> }
>
> ...
> }
>
> location = /403.html {
> # no geoip restrictions here
> }
> }
>
> With such a configuration GeoIP-based restrictions are only
> applied in "location /", but doesn't affect requests to /403.html.
> That is, nginx will be able to return the error page correctly.
>
> --
> Maxim Dounin
> http://nginx.org/
>
> ___
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
___
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Re: No Source RPMs for rhel package

2017-02-01 Thread Tseveendorj Ochirlantuu
Hi


Source oos ni compile hiiheer amar yum shig sanagddag.

You can compile from source http://nginx.org/download/nginx-1.10.3.tar.gz



On Wed, Feb 1, 2017 at 4:25 PM Natsagdorj, Shagdar 
wrote:

> Hi all,
>
>
>
> Is there a particular reason why there are no Source RPMs under
> http://nginx.org/packages/rhel/7/SRPMS/ for the stable versions 1.10.2
> and 1.10.3 ?
>
>
>
> Best Regards,
>
> Nagi
> ___
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
___
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Re: Too many redirects

2017-09-14 Thread Tseveendorj Ochirlantuu
Thank you Francis Daly. It works.

On 15 Sep 2017 5:45 am, "Francis Daly"  wrote:

On Thu, Sep 14, 2017 at 11:54:23PM +0800, tseveendorj wrote:

Hi there,

> location / {
> index index.html;
> if ($geoip_country_code != "JP") { return 301
> https://example.com/en/; }
> }

> location = /en/ {

Change that to "location /en/ {" or "location ^~ /en/ {".

> index index.html;
> try_files $uri $uri/ =404;
> }
>
> I'm trying to if request from other than JP request go to /en/ if
> not /index.html

You request /en/, which is processed in the second location. That does
an internal redirect to /en/index.html, which is processed in the first
location and returns a 301 redirect to /en/, so you have a loop.

Change "location =" to break the loop, so that the request to
/en/index.html is not handled in the first location.

f
--
Francis Dalyfran...@daoine.org
___
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
___
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Re: rewrite difficulty

2013-08-01 Thread Tseveendorj Ochirlantuu
Hello,

My understanding is on Apache rules like follow and convert it to nginx

If anyone request anything except follow URI /file/, /install/, /design/,
/plugins/, /phpmyadmin/ then nginx will forward anything to
/index.php?do=anything

RewriteCond %{REQUEST_URI} !^/file/.*
RewriteCond %{REQUEST_URI} !^/install/.*
RewriteCond %{REQUEST_URI} !^/design/.*
RewriteCond %{REQUEST_URI} !^/plugins/.*
RewriteCond %{REQUEST_URI} !^/phpmyadmin/.*
RewriteRule ^(/.*)$ /index.php?do=$1 [L]

nginx

location / {
if ( $request_uri !~ ^(/file/|/install/|/design/|/plugins/|/phpmyadmin/)) {
rewrite ^(/.*)$ /index.php?do=$1;
}
}

Is this right ? It works on my server. I'm confusing where I need to put
this rewrite. Am I right ?


On Tue, Apr 30, 2013 at 10:01 AM, Jonathan Matthews  wrote:

> On 30 April 2013 03:36, tseveendorj  wrote:
> > Hello,
> >
> > I have difficulty to convert apache like rewrite to nginx. This is my
> config
> > file of virtualhost on nginx.  http://pastebin.com/HTtKXnFy
>
> OMFG. You win today's prize for "Nginx config I am least likely even
> to /try/ and change". Congrats! ;-)
>
> > My installed php script should have following rewrite
> > http://pastebin.com/M2h3uAt3
> >
> > Currently any requested php code displayed it's source on browser. How
> could
> > I migrate ?
>
> You need to start small. Learn how Nginx does its thing in one small
> area and when you've understood that, move on the next.
>
> At the moment, you have literally picked up your apache config and
> dumped it into Nginx's config syntax. You are unlikely to succeed if
> you don't learn how to work *with* Nginx, instead of trying just to
> make it behave like Apache.
>
> This may not be the "here's your config; I fixed it" reply you were
> looking for, but it's the best I can give you. Your Nginx config is
> /horrible/, and I'm not going to spend my time deciphering it! :-)
>
> Have a *really* good read of
> http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite and
> http://wiki.nginx.org/HttpRewriteModule. They'd be good places to
> start ...
>
> J
> --
> Jonathan Matthews // Oxford, London, UK
> http://www.jpluscplusm.com/contact.html
>
> ___
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
___
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx