D
D
Drno2022-01-23 13:00:31
Nginx
Drno, 2022-01-23 13:00:31

How to change the proxy_pass config correctly?

Good afternoon. There was a question yesterday, but it does not take off.
We have a regular (test) nginx, we need to redirect using proxy_pass

if location is specified / (as root) everything works fine, there are no problems.
But I want /redirect to be specified (any other link doesn't matter)... but then site.ru/redirect opens... and even I can't get rid of it with rewrite... Help kind people)
Yes, I tried add a slash at the end of the domain - does not help...

a piece of the config

location /redirect {
    proxy_pass https://www.google.com;
    proxy_buffering 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;
    proxy_redirect default;
    }


In general, how to write rewrite correctly - I don’t get it ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
ky0, 2022-01-23
@ky0

proxy_pass https://www.google.com;- so, of course, will not work. Otherwise, anyone could take and start proxying any services, sniffing passwords along the way. Do you need the url to /redirectopen the main page of Google or something?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question