I
I
Ilya Izumskee2015-05-06 17:06:21
Nginx
Ilya Izumskee, 2015-05-06 17:06:21

How to redirect from domainA.com to domainB.com/url?

Greetings!
There are 2 domains located on the same hosting. It is necessary that when going to domain1.com, the user sees the page domain2.com/page. The URL must remain domain1.com.
On the Nginx + NodeJS server.
So far, I've made it through nginx.conf so that domain1 looks at the same port as domain2 through proxy_pass.
I have no idea how to proceed.
Thank you for your help.
nginx.conf snippet

server {
    listen IP:80;
    server_name domain2.com;

    location / {
        proxy_pass http://127.0.0.1:3001;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

server {
    listen      IP:80;
    server_name domain1.com 

    location / {
        proxy_pass http://127.0.0.1:3001;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergei, 2015-05-06
@viruhost

Isn't it easier to change the Patch Directory for domain2

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question