Some solutions about redirection can be found. But what I want to do is redirecting part of requests to another server, specifically, only when a request url includes string “service”. For example:
http://localhost/service/image————-> http://localhost:8080/service/image
http://localhost/service/image/upload——> http://localhost:8080/service/image/upload
http://localhost/service/blog————–> http://localhost:8080/service/blog
…..
……………………………………………………………………………………………………………………………………………..
but blow will still served by ngnix,cause no “service” included within url
How to do this?
You need to use location regex matching together with proxy_pass, example:
^/servicewill match any request beginning with/serviceand forward it to Apache.proxy_passis transparent for the user, i.e. it will forward the request to Apache and return the output to the user.For more info on location matching, checkout http://wiki.nginx.org/HttpCoreModule#location