首页 新闻 会员 周边

nginx 本地代理问题

0
悬赏园豆:10 [待解决问题]

server {
        listen       9911;
        server_name  dev.xxx.cn localhost;

        location / {
            if ( !-f http://localhost:8001/assets/plugin-web-layout5/plugin-web-layout5.js ) {
                rewrite ^/assets/plugin-web-layout5/plugin-web-layout5 http://localhost:8001/assets/plugin-web-layout5/plugin-web-layout5.js;
            }

            proxy_pass http://dev.xxx.cn/web/;
        }

        location /api {
            proxy_pass http://s3.dev.ekuaibao.cn/api;
        }
    }

nginx配置如上,现在的问题是if里面的判断,在localhost:8001没有启动的时候也执行了,报错如下:

GET http://localhost:8001/assets/plugin-web-layout5/plugin-web-layout5.js net::ERR_CONNECTION_REFUSED 200

请问需要在怎么写if。

唐岗的主页 唐岗 | 初学一级 | 园豆:176
提问于:2021-12-28 17:04
< >
分享
所有回答(1)
0
wang_yb | 园豆:4891 (老鸟四级) | 2021-12-28 22:05
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册