【发布时间】:2015-10-19 01:31:01
【问题描述】:
我在主机上有一个 java 网络服务器
http://192.168.0.1:80
此主机不是本地,它是通过 VPN 从 Internet 访问的。我在主机上有文件:
http://192.168.0.1:80/100mbFile.zip
当我直接用 Opera 或 Firefox 下载它时,我得到了 32-35 kb/s 的下载速度。
但是当我使用本地安装的 Nginx 访问此文件时,使用 x3 的速度更快。配置是这样的:
# I simplify the config removing unnesessary information from it.
server {
listen 8080;
server_name nginx.local;
location /download {
rewrite /download /auth_download last;
# /auth_download return X-Accell-Redirect to /internal_download
}
location /internal_download {
proxy_intercept_errors on;
proxy_pass http://192.168.0.1:80/100mbFile.zip;
}
}
}
文件以大约 140 kb/s 的速度下载。为什么?总结:
Opera -> http://192.168.0.1:80/100mbFile.zip - ~35kb/s
Opera -> http://nginx.local:8080/download (Local Nginx proxy_pass) - ~140kb/s
这怎么可能? Nginx 本地安装在 127.0.0.1 上,互联网连接相同,带宽也相同。都是一样的。 Nginx conf 中没有使用缓存。我的操作系统是 Windows XP
【问题讨论】:
-
你不是说 proxy_pass 比较慢吗?当您访问端口 80 上的文件时,您的下载将由您的 java Web 服务器提供。当您使用 8080 时,您的下载由 nginx 直接提供。这就是为什么它更快。您在端口 8080 上的访问不是代理传递。
-
@AshrayBaruah 不,proxy_pass 比直接访问更快
-
nginx.local解析到什么IP?
-
nginx.local 是 127.0.0.1。我正在使用 nginx 大约 2 年,这种情况非常严重
-
@AshrayBaruah。不不不! proxy_pass 更快,更快
标签: performance nginx