How does nginx perform different operations based on the response of the proxy server?

WBOY
Release: 2023-03-02 09:16:01
Original
1075 people have browsed it

There is a problem. Some pictures exist on the local server, and some exist on third-party servers.
And the picture names are similar ~ it’s hard to distinguish ~
So I want to configure a proxy. If it can’t be found on the local server, proxy it to the third-party server. Third-party server.
How to configure this nginx?


Final solution:

<code>location /{
        root  xxxxx;
        index index.html;
        if (!-e $request_filename) {
            proxy_pass yyyyyy;
        }
    }</code>
Copy after login
Copy after login

Reply content:

There is a problem. Some pictures exist on the local server, and some exist on third-party servers.
And the picture names are similar ~ it’s hard to distinguish ~
So I want to configure a proxy. If it can’t be found on the local server, proxy it to the third-party server. Third-party server.
How to configure this nginx?


Final solution:

<code>location /{
        root  xxxxx;
        index index.html;
        if (!-e $request_filename) {
            proxy_pass yyyyyy;
        }
    }</code>
Copy after login
Copy after login

Error redirect

location /{

<code>error_page   404   @test;</code>
Copy after login

}

location @test{

<code>proxy_pass http://upstreamName;</code>
Copy after login

}

Finally solved this~

<code>location /{
        root xxxx;
        index index.html;
        if (!-e $request_filename) {
            proxy_pass yyyyyyyyy;
        }
    }</code>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!