在virtualhost中增加如下

server {
    listen  3128;
    location / {
        resolver 8.8.8.8;                   #DNS
        proxy_pass http://$http_host$request_uri;
    }
    #access_log /var/log/nginx/http_proxy.log;
}

然后重启nginx服务即可.