proxy_pass nginx. redirect to another domain in location path

15 Views Asked by At

I need to go to another site when following the path of the site This design works, and I successfully navigate and see this site through my link, but I get 404 responses

server_name 1.1.1.1.nip.io
        location /example/ {
        proxy_pass https://example.com;
        proxy_set_header   Host             $proxy_host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        }

when I click on the link 1.1.1.1.nip.io/example/ I see the content of the site I need https://example.com. But postman (and browser) Status code is 404 | AssertionError: expected response to have status code 200 but got 404, because the original request was for a website 1.1.1.1.nip.io/example/ Please tell me how to fix it so that the answer comes Status code is 200.

I tried everything I knew

1

There are 1 best solutions below

0
nocodre On

put it on

rewrite /example/(.*) /  break;

so that the path points to an existing page, and it already returns a 200 response