0

We already have an existing domain running in production (my.domain1) and we wanted to create another domain which will be hosted in a separate server (my.domain2) which will serve pages that are already available from the production domain. If I access "my.domain2/my_account.html", nginx should then get the content of the page from "my.domain1/profile.html". Unfortunately, I'm always getting 404 message. I've ready so many articles on how to use proxy_pass but I think I'm missing something. Please help.

Here is my configuration for domain1:

server {
  listen 80;
  root /var/www/domain1;
  index index.html index.htm;
  server_name my.domain1;
}

and here is for the domain2:

server {
  listen 80;
  root /var/www/domain2;
  index index.html index.htm;
  server_name my.domain2;
  location /my_account.html {
    proxy_pass http://my.domain1;
    proxy_redirect off;
  }
}

2 Answers 2

4

I've already figured it out. I'll just have to basically specify the equivalent url for both domain1 and domain2. Below is my final configuration. Hope it helps someone out there.

server {
    listen 80;
    root /var/www/domain1;
    index index.html index.htm;
    server_name my.domain1;
}

and here is for the domain2:

server {
    listen 80;
    root /var/www/domain2;
    index index.html index.htm;
    server_name my.domain2;
    location /my_account.html {
        proxy_pass http://my.domain1/profile.html;
    }
}
0

Use:

server {
   listen 80;
   root /var/www/domain1;
   index index.html index.htm;
   server_name my.domain1;
 }

server {
   listen 80;
   root /var/www/domain1;
   index index.html index.htm;
   server_name my.domain2;
 }

Basically just make the root directive the same as that for domain 1

1
  • This is not possible as the domains are hosted in separate servers. Sorry for the confusion. I've updated the question for it. Commented Nov 6, 2013 at 1:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.