Lots of work in a location block

Hi Folks,

I’m trying to integrate a python backend into a pre-existing php
website, and am having problems doing this as I need to rewrite the url
at the same time… eg: this is what isn’t working.

location = /example {
rewrite /example/(.*) /$1 break;

root /www/example;

include proxy_params;
proxy_pass http://python;

#break;

}
( stripped to bare essentials )

So it’s

  • strip off the /example prefix
  • set the new root ( the php site sets is outside any location block )
  • pass stripped request to the python backend.

I’ve tried every option I can think of, but they all seem to drop out of
the location block and process the rewritten request again, which means
that they’re not using the static files in the locally defined root, and
also aren’t being handed to the python backend for processing.

I’ve fudged it for the moment, but would really like to do it properly!

Cheers,

Steve.

Oh, proxy_params contains

proxy_next_upstream error timeout invalid_header http_500 http_502
http_503 http_504;
proxy_redirect off;
proxy_buffering 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;


Steve H. BSc(Hons) MIITP
http://www.greengecko.co.nz
Linkedin: http://www.linkedin.com/in/steveholdoway
Skype: sholdowa

On Wednesday 18 June 2014 12:15:29 Steve H. wrote:

Hi Folks,

I’m trying to integrate a python backend into a pre-existing php
website, and am having problems doing this as I need to rewrite the url
at the same time… eg: this is what isn’t working.

location = /example {

The only request, that will be handled by your location with “=”
modifier
is “/example”, even “/example/” isn’t fit.

So it’s

  • strip off the /example prefix
  • set the new root ( the php site sets is outside any location block )
  • pass stripped request to the python backend.
    […]

Please note, that the “root” directive is almost meaningless in location
with “proxy_pass”.

And you don’t need “rewrite”.

Something like that should work:

location /example/ {
include proxy_params;
proxy_pass http://python/;
}

Please also check the docs:

http://nginx.org/r/proxy_pass
http://nginx.org/r/location

wbr, Valentin V. Bartenev

That’s a red herring… cut/paste error. The rewrite is being processed,
the result isn’t being passed to the proxy server.

On Wednesday 18 June 2014 19:35:02 Steve H. wrote:

That’s a red herring… cut/paste error. The rewrite is being processed,
the result isn’t being passed to the proxy server.

[…]

Without a full and exact copy of your configuration there’s no way
to help you. Every single bit of it has meaning. You are assuring
us that the configuration is ok, then where is the problem?

wbr, Valentin V. Bartenev

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs