开发者

How to configure nginx.conf so that I can use nginx as proxy to visit other sites?

I'm doing it this way but always get 404 page:

location / {
                proxy_pass        http://localhost:81;
                proxy_set_header  X-Real-IP  $remote_addr;
        }

Requested tried:

telnet localhost 81

GET http://stackoverflow.com/ HTTP/1.1
Host: stackoverflow.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:1.9.2.17) Gecko/20110420 AlexaToolbar/alxf-2.11 Firefox/3.6.17
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-cn,zh;q=0.5
Accept-Encoding: gzip,deflate
Accept-Ch开发者_开发知识库arset: GB2312,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Cookie: A=t;
Cache-Control: max-age=0

Result got:

HTTP/1.1 404 Not Found
Server: nginx/1.0.2
Date: Tue, 24 May 2011 00:30:51 GMT
Content-Type: text/html
Content-Length: 168
Connection: keep-alive

<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.0.2</center>
</body>
</html>


location / {
    proxy_pass http://$http_host$request_uri;
}

resolver 8.8.8.8;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜