歡迎您光臨本站 註冊首頁

squid後面的nginx如果有proxy_pass的話會504?

←手機掃碼閱讀     火星人 @ 2014-03-04 , reply:0

squid後面的nginx如果有proxy_pass的話會504?

把nginx放到了squid後面,一般的server都沒有問題,有一個server裡面使用了proxy mod,這時通過squid訪問proxy過得url就會504,而直接訪問沒有問題,具體描述:

1.nginx配置

server {
  listen   192.168.0.10:80;
  server_name  tech.test.com;
  proxy_next_upstream error;

  location = /data/js/config.js {
      root              /opt/tmp/test;
  }

  location /news {
      proxy_pass        http://news.test.net;
      proxy_redirect           off;
      proxy_set_header         Host $host;
      proxy_set_header         X-Real-IP $remote_addr;
      proxy_set_header         X-Forwarded-For $proxy_add_x_forwarded_for;
  }
}

起來后直接訪問http://tech.test.com/data/js/config.js和http://tech.test.com/news/xx.html沒有問題

2.前面加上一個squid,通過squid訪問http://tech.test.com/data/js/config.js沒有問題,訪問http://tech.test.com/news/xx.html就會 504 gateway timeout,nginx錯誤日誌:

2008/09/23 08:58:43 17645#0: *1 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 127.0.0.1, server: tech.test.com, request: "GET /news/2008/0912/16357.html HTTP/1.0", upstream: "http://192.168.0.16:80/news/2008/0912/16357.html", host: "tech.test.com"

怎麼解決呢?謝謝

[火星人 ] squid後面的nginx如果有proxy_pass的話會504?已經有346次圍觀

http://coctec.com/docs/service/show-post-27418.html