nginx反向代理到本地响应慢的解决方案

本地的nginx反向代理到本地的静态服务器,竟然慢的要死

server {
        listen       8888;
        server_name  localhost;
        root "E:\Project\scratch-flash\mkt";
        location / {
            index  index.html index.htm;
           autoindex  on;
        }
    }
server {
        listen  80;
        server_name  localhost;
        client_max_body_size 10M;
        location / {
            proxy_pass http://localhost:8080/;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }

        location /mkt/ {
            proxy_pass http://localhost:8888/;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_connect_timeout 1;
            add_header 'Access-Control-Allow-Origin' '*';
        }
}

增加一个配置即可
proxy_connect_timeout

3 条评论

点击这里取消回复。

[/0o0] [..^v^..] [0_0] [T.T] [=3-❤] [❤.❤] [^v^] [-.0] [!- -] [=x=] [→_→] [><] 更多 »
昵称
  1. xc Google Chrome 71 Google Chrome 71 Mac OS X 10.14 Mac OS X 10.14

    windows下localhost有bug, 改成127.0.0.1就可以

    1. 鸽子 鸽子 Google Chrome 70 Google Chrome 70 Windows 10 Windows 10

      原来是这样 [..^v^..]

    2. DHclly Google Chrome 69 Google Chrome 69 Windows 10 Windows 10

      这是bug啊,哈哈 [T.T]