B
B
BloodVIRUS2019-07-15 14:04:23
Nginx
BloodVIRUS, 2019-07-15 14:04:23

How to properly proxy a site on nginx?

Hello. I want to do proxying on my own server. That is, site2.ru opened on the site1.ru/subfolder site Without redirects, and site1.ru/subflder
would still hang in the browser. On one of its servers, the config below worked. But it had ancient versions of php, nginx, mysql, so I raised all the most current versions on another server (php 7.3, Mysql 10.4.6, nginx 1.17.1). But the same config did not want to work, I get a 504 error, and Google is silent ..

location /subflder/ {

                proxy_pass http://site2.ru/;
                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 site2.ru;
                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;
        }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Skibin, 2019-07-15
@megafax

proxy_pass http://site2.ru/;
this is how it should be
proxy_pass http://<IP адрес сайта:порт>/;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question