0

I've setup nginx on an Amazon EC2 instance I've purchased but I am stuck with the most basic question. How would I be able to route all the requests to another remote address. Assume that you have the sites a.com and b.com. So when user makes a requests like;

  • a.com/bringMeStuff -> (it should route it to) b.com/bringMeStuff
  • a.com -> (it should route it to) b.com

I have tried methods like proxy_pass, rewrite but what I want to do exactly is to route all the urls to the other remote server. Would it be possible?

2 Answers 2

2

Could you elaborate what do you mean by routing all URLs ? It'll be better if you explain it on HTTP level, like what you expect to see in HTTP response (200, 301, 302, etc.) when a request for http://domain1.tld/foo/bar comes.

2

You can try rewrite module like this:

server {
        listen       80;
        server_name  a.com;
        rewrite         ^ $scheme://b.com$request_uri permanent;
    }
3
  • In the conf I have there is http {} defined. Should I delete it and later on add the server {} ?
    – Ali
    Feb 21, 2013 at 12:14
  • you should add server{} scope inside http{} scope
    – Serhat
    Feb 21, 2013 at 12:22
  • I have a problem with the JSON data sending. I did not understand why but the JSON data is not being conceived by the b.com
    – Ali
    Feb 21, 2013 at 12:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .