Rewrite proxy flag set problem

Hi

  I have write a one rewrite rule as below

rewrite /auction(.*)$ http://192.168.1.210$1;

This rewrite rule working fine for me.

but the problem is it show the Ip address 192.168.1.210 also.

I want to hide this IP , for that in apache flage [P] is there.

but Nginx I dont know how to set proxy flag [P]. Please guide for the
same.

Posted at Nginx Forum:

Hello!

On Fri, Mar 23, 2012 at 07:16:37AM -0400, niraj wrote:

I want to hide this IP , for that in apache flage [P] is there.

but Nginx I dont know how to set proxy flag [P]. Please guide for the
same.

Use

location /auction/ {
proxy_pass http://192.168.1.210/;
}

instead.

Maxim D.

Hi

 I know that solution but it will not work in my case, I am using

the reguralar expression.

Proxy pass not support regural expression right ?

Posted at Nginx Forum:

You state that “it will not work in my case [as] I am using the
regular expression”, but don’t provide any examples of how you’re
doing this or how it breaks.

Please provide a fuller and more complete set of examples.

You could also try removing the trailing slash from Maxim’s rewritten
example. i.e.

location /auction/ {
proxy_pass http://192.168.1.210;
}

This will pass on the remainder of the URI’s path more equivalently to
your original example.

Jonathan

Jonathan M.
London, Oxford, UK
http://www.jpluscplusm.com/contact.html

Is there any other way to complete my requirement ??

Posted at Nginx Forum:

Hi

I have installed the catalyst and I am trying to integrate the same
with Nginx.

rewrite /auction(.*)$ http://192.168.1.210$1;

the following rewrite rule is working for me right now.

If I write rule that u mentioned then it will gives the error

location /auction/ {
proxy_pass http://192.168.1.210;
}

The reason for error might is that because my request is just like…

http://192.168.1.45/auction?id=1332416535292370.0097187543142212

for that I required to write a regular expression

rewrite /auction(.*)$ http://192.168.1.210$1;

Hope Now you understand my point clearly.

If required any other info then let me know.

Posted at Nginx Forum:

Hi

 Let me clear my question again.

 My current problem is  if I used the rewrite rules  my site is

working(this is my testing machine so Ip just like 192.168…), but
problem is it not show the original server Ip , instead it show the
192.168.1.210 at client side, I want to hide this Ip 192.168.1.210.
want to show the original server IP when redirect happened.
Hope you clear with my requirement.

Now I have set this in nginx, I just give u my nginx configuration
details as below

server {
listen 80;
server_name localhost;

#charset koi8-r;
#access_log  /var/log/nginx/log/host.access.log  main;

location / {
    root   /var/www/vendx/html_asp;
    index  index.html index.shtml;
}


location  \.(js|css|png|jpg|jpeg|gif|ico|html|xml)$ {}

location /auction/ {
proxy_pass http://192.168.1.210;
}

location ~ \.(cgi|pm)$ {
gzip off;
include /etc/nginx/fastcgi_params;
fastcgi_pass  unix:/var/run/fcgiwrap.socket;
fastcgi_index index.cgi;
fastcgi_param SCRIPT_FILENAME  /var/www/vendx$fastcgi_script_name;
#fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;

}

I am getting the following error when redirect happened

2012/03/26 17:32:24 [error] 5349#0: *1 open()
“/var/www/vendx/html_asp/stylesheet” failed (2: No such file or
directory), client: 192.168.1.44, server: localhost, request: “GET
/stylesheet HTTP/1.1”, host: “192.168.1.45”, referrer:
http://192.168.1.45/auction/?id=1332416535292370.0097187543142212
2012/03/26 17:32:24 [error] 5349#0: *5 open()
“/var/www/vendx/html_asp/static/images/error.png” failed (2: No such
file or directory), client: 192.168.1.44, server: localhost, request:
“GET /static/images/error.png HTTP/1.1”, host: “192.168.1.45”, referrer:
http://192.168.1.45/auction/?id=1332416535292370.0097187543142212
2012/03/26 17:32:24 [error] 5349#0: *1 directory index of
“/var/www/vendx/html_asp/scripts/” is forbidden, client: 192.168.1.44,
server: localhost, request: “GET /scripts/ HTTP/1.1”, host:
“192.168.1.45”, referrer:
http://192.168.1.45/auction/?id=1332416535292370.0097187543142212
2012/03/26 17:32:24 [error] 5349#0: *1 open()
“/var/www/vendx/html_asp/static/images/error.png” failed (2: No such
file or directory), client: 192.168.1.44, server: localhost, request:
“GET /static/images/error.png HTTP/1.1”, host: “192.168.1.45”, referrer:
http://192.168.1.45/auction/?id=1332416535292370.0097187543142212

Posted at Nginx Forum:

On 26 March 2012 13:27, niraj [email protected] wrote:

Hi

Let me clear my question again.

My current problem is  if I used the rewrite rules  my site is

working(this is my testing machine so Ip just like 192.168…), but
problem is it not show the original server Ip , instead it show the
192.168.1.210 at client side, I want to hide this Ip 192.168.1.210.

Yes - as I explained, that’s because you were using a redirect with an
http:// prefix. That’s what it does.

want to show the original server IP when redirect happened.
Hope you clear with my requirement.

“Requirements” are what you give to people you’re paying to help you.
I think you mean “this is what I’m try to achieve” … :wink:

}
I think I’ve already suggested the small change that you need to try
here. Read my previous email again.

I am getting the following error when redirect happened

Are these errors in the nginx logs? Ort the logs on 192.168.1.210? In
response to what single initial request exactly?
Have a read of How To Ask Questions The Smart Way
and the rest of that document - it may help.

Cheers,
Jonathan

On 26 March 2012 12:39, niraj [email protected] wrote:

Hi

I have installed the catalyst and I am trying to integrate the same
with Nginx.

I don’t know what “the catalyst” is, sorry. I’m not sure I need to,
however.

rewrite /auction(.*)$ http://192.168.1.210$1;

the following rewrite rule is working for me right now.

If I write rule that u mentioned then it will gives the error

location /auction/ {
proxy_pass http://192.168.1.210;
}

You need to tell us what “the error” is. Just saying that an error
occurs really isn’t helpful.

The reason for error might is that because my request is just like…

http://192.168.1.45/auction?id=1332416535292370.0097187543142212

for that I required to write a regular expression

rewrite /auction(.*)$ http://192.168.1.210$1;

Yes, you need to amend the location clause Maxim and I gave you so
that it doesn’t mandate a trailing slash. NB this is a different
trailing slash from the one I mentioned previously in this thread.

You need not to use any rewrite statements in the way that you’re
currently doing. As
Module ngx_http_rewrite_module says: “If the
replacement string begins with http:// then the client will be
redirected”.
This means that the only reason the rewrite is working for you is
because your client machine has direct access to 192.168.1.210. If you
try to make this work for external users, it won’t.

Use the “location” method instead of using “rewrite”. Get rid of the
trailing slash.

Jonathan

Jonathan M.
London, Oxford, UK
http://www.jpluscplusm.com/contact.html

Hi

Sorry for that Mess up.

As u suggested I have added the following line

location /auction/ {
proxy_pass http://192.168.1.210;

when I click into my application I got the error that I mentioned in
earlier e-mail.

that error log of original server (192.168.1.45) and there is no log
for 192.168.1.210 error log file.

this is the request that my application is sending to the Nginx

auction?id=1332416535292370.0097187543142212

In above example and as u suggested it will proxy or redirect the
/auction folder query to the http://192.168.1.210;

but you can see above request its not call the /auction folder.

so we required to do something like auction(.*) am I correct ?

And As I know proxy_pass not support the regular expression (.*) is
it correct ?

Posted at Nginx Forum:

HI

I was trying the with the following changes

location /auction(.*)$1 {
proxy_pass http://192.168.1.210$1/;
}

It was giving the following error

2012/03/27 10:32:39 [error] 7871#0: *1 open()
“/var/www/vendx/html_asp/auction” failed (2: No such file or directory),
client: 192.168.1.44, server: localhost, request: “GET
/auction?id=1332416535292370.0097187543142212 HTTP/1.1”, host:
“192.168.1.45”, referrer:
http://192.168.1.45/cgi-bin/baybuy_vendx/index.cgi?vendx_action=productlist&ShowPopup=1&pageid=10445&ID=20815613327607825242140023430669

Posted at Nginx Forum:

On Tue, Mar 27, 2012 at 09:18:39AM +0400, Igor S. wrote:

when I click into my application I got the error that I mentioned in
In above example and as u suggested it will proxy or redirect the
It seems you need just these two locations:

location = /auction {
proxy_pass http://192.168.1.210;
}

to proxy requests like “/auction?id=1332416535292370.0097187543142212”

Or

location = /auction {
proxy_pass http://192.168.1.210/;
}

if request “/auction?id=1332416535292370.0097187543142212” should be
proxied to “http://192.168.1.210/?id=1332416535292370.0097187543142212”.


Igor S.

On Tue, Mar 27, 2012 at 12:29:06AM -0400, niraj wrote:

earlier e-mail.
/auction folder query to the http://192.168.1.210;

but you can see above request its not call the /auction folder.

so we required to do something like auction(.*) am I correct ?

And As I know proxy_pass not support the regular expression (.*) is
it correct ?

You do not need regular expression in this case.
It seems you need just these two locations:

location = /auction {
proxy_pass http://192.168.1.210;
}

to proxy requests like “/auction?id=1332416535292370.0097187543142212”

And

location /auction/ {
proxy_pass http://192.168.1.210/;
}

to proxy “/auction/some/page” to “http://192.168.1.210/some/page”.


Igor S.

On Tue, Mar 27, 2012 at 01:47:20AM -0400, niraj wrote:

}

Tnx for the solution. And thnx for understanding the requirement.

I have googling so much but I did not find this = syntax
would you suggest for Nginx doc link in that I found such details
docs.

http://nginx.org/en/docs/http/ngx_http_core_module.html#location


Igor S.

Hi

Thnx for link.  We can not do the same with rewrite ?

for me with rewrite it was working but the only problem was that the url
not proxied. its show the 192.168.1.210 at user end instead showing the
original server name(my case 192.168.1.45).

we can not solve that with rewrite ???

Posted at Nginx Forum:

Hi

Tnx a lot.

          that is what exactly I want to do  I have done the

following and its works.

location = /auction {
proxy_pass http://192.168.1.210/;
}

Tnx for the solution. And thnx for understanding the requirement.

I have googling so much but I did not find this = syntax
would you suggest for Nginx doc link in that I found such details
docs.

Posted at Nginx Forum:

Hi

As I read and from that I understand, Proxypass in apache not used

for regular express.

mostly for regular expression in apache used the rewriterule

mod_rewrite - Apache HTTP Server Version 2.4

The mod_rewrite module uses a rule-based rewriting engine, based on a
PCRE regular-expression parser, to rewrite requested URLs on the fly

Please correct me If I wrong.

Posted at Nginx Forum:

On Tue, Mar 27, 2012 at 02:52:30AM -0400, niraj wrote:

PCRE regular-expression parser, to rewrite requested URLs on the fly

Please correct me If I wrong.

Yes, Apache did not support regexes ProxyPass.
However, in your case regexes are not needed:

ProxyPass /auction http://192.168.1.210/

or

<Location /auction>
ProxyPass http://192.168.1.210/


Igor S.

Hi

I tried

Proxy_Pass /auction http://192.168.1.210/;

its not working gives the following error

nginx: [emerg] invalid number of arguments in “proxy_pass” directive in
/etc/nginx/conf.d/default.conf:52
nginx: configuration file /etc/nginx/nginx.conf test failed

Posted at Nginx Forum:

On Tue, Mar 27, 2012 at 02:07:34AM -0400, niraj wrote:

Hi

Thnx for link.  We can not do the same with rewrite ?

for me with rewrite it was working but the only problem was that the url
not proxied. its show the 192.168.1.210 at user end instead showing the
original server name(my case 192.168.1.45).

we can not solve that with rewrite ???

No, you cannot proxy with rewrite in nginx.

As to the rewrite usage itself, this is a wrong, cumbersome,
and ineffective way of configuration in both nginx and Apache.


Igor S.