鍍金池/ 問答/Linux/ nginx代理轉(zhuǎn)發(fā)“/api”無效:用內(nèi)網(wǎng)報的200,用外網(wǎng)直接會報504,請求

nginx代理轉(zhuǎn)發(fā)“/api”無效:用內(nèi)網(wǎng)報的200,用外網(wǎng)直接會報504,請求超時了

我本地開發(fā)需要用到 http://api.map.baidu.com/ 的百度 api。但是瀏覽器會出現(xiàn)跨域問題。
想用nginx反向代理解決,但是nginx的配置好像不起作用。下面是nginx的配置:

server {
        listen       8888;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

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

        #error_page  404              /404.html;

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

clipboard.png

用公司內(nèi)網(wǎng)會會直接到公司的錯誤頁面 雖然報的200,用外網(wǎng)的話直接會報504,請求超時了,弄了半天也不知道為什么。

回答
編輯回答
安于心

你好,問題解決了嗎

2018年1月3日 12:58