T
T
TechNOIR2018-04-04 09:16:50
Nginx
TechNOIR, 2018-04-04 09:16:50

nginx. How to make a site mirror through Proxy pass?

Good afternoon.
I comprehend Nginx) Please tell me how to make a site mirror through Proxy pass?
That is, when you go to the SITE1.COM site, SITE2.COM is loaded without changing the address. Ie not a redirect as a matter of fact.
Is it possible at all?
Tried like this:

server {
    listen 9999;
    server_name site1.com;
    access_log /var/log/nginx/test/access.log;
    error_log /var/log/nginx/test/error.log;

location / {
    proxy_pass http://site2.com
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    }
}

But there is a redirect

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
awesomer, 2018-04-04
@awesomer

location / {
                resolver 8.8.8.8;

                proxy_cache my_cache;

                proxy_pass https://example.com;
                proxy_redirect off;

                proxy_intercept_errors on;

                proxy_set_header X-Forwarded-Host $host;
                proxy_set_header X-Forwarded-Server $host;
                proxy_set_header Host example.com;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-Proto $scheme;
        }

taken from a currently working proxy
, you can access it both at example.com
and at the address (domain name) on which this same nginx is installed.
simultaneously.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question