Invalid "/ api" forwarded by nginx agent: 200 reported by internal network, 504 directly by external network, request timed out

my local development needs Baidu api using http://api.map.baidu.com/. But browsers can have cross-domain problems.
wants to use nginx reverse proxy to solve the problem, but the configuration of nginx doesn"t seem to work. The following is the configuration of nginx:

server {
        listen       8888;
        server_name  localhost;

        -sharpcharset koi8-r;

        -sharpaccess_log  logs/host.access.log  main;

        location / {    
            
           root C:\publish; 
        index index.html index.htm;
        }
        location ^~ /apis/  {
            proxy_pass   http://api.map.baidu.com/;
       }

        -sharperror_page  404              /404.html;

        -sharp redirect server error pages to the static page /50x.html
        -sharp
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

clipboard.png

using the company"s intranet will go directly to the company"s error page, although it will report 200, and if you use the external network, it will directly report 504, and the request has timed out, and I don"t know why I"ve been doing it for a long time.

Mar.09,2021

Hello, have you solved the problem

Menu