问题描述
我需要一些Linux专家的帮助.我正在使用包含彗星服务器的webapp.彗星服务器运行在localhost:8080上,并公开URL localhost:8080/long_polling供客户端连接.我的webapp在localhost:80上运行.
I need some help from some linux gurus. I am working on a webapp that includes a comet server. The comet server runs on localhost:8080 and exposes the url localhost:8080/long_polling for clients to connect to. My webapp runs on localhost:80.
我已经使用nginx代理了从nginx到彗星服务器的请求(将localhost:80/long_polling代理为localhost:8080/long_polling),但是,使用此解决方案有两个问题:
I've used nginx to proxy requests from nginx to the comet server (localhost:80/long_polling proxied to localhost:8080/long_polling), however, I have two gripes with this solution:
- nginx一分钟后为我提供了504网关超时,即使我将每个单次超时设置更改为600秒
- 我真的不希望nginx必须代理到彗星服务器-nginx代理不是为建立持久连接而建立的(可能长达半小时).我宁愿允许客户端直接连接到彗星服务器,并让彗星服务器处理它.
- nginx gives me a 504 Gateway time-out after a minute, even though I changed EVERY single time out setting to 600 seconds
- I don't really want nginx to have to proxy to the comet server anyway - the nginx proxy is not built for long lasting connections (up to half an hour possibly). I would rather allow the clients to directly connect to the comet server, and let the comet server deal with it.
所以我的问题是:是否有任何Linux技巧可以使我在不使用nginx代理的情况下将localhost:8080/long_polling公开给localhost:80/long_polling?一定有东西这就是为什么我认为Linux专家可能会最好地回答这个问题.
So my question is: is there any linux trick that allows me to expose localhost:8080/long_polling to localhost:80/long_polling without using the nginx proxy? There must be something. That's why I think this question can probably be best answered by a linux guru.
我需要/long_polling暴露在端口80上的原因是,这样我就可以使用AJAX进行连接(ajax same-origin-policy).
The reason I need /long_polling to be exposed on port 80 is so I can use AJAX to connect to it (ajax same-origin-policy).
这是我的nginx proxy.conf供参考:
This is my nginx proxy.conf for reference:
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;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
send_timeout 600;
proxy_buffering off;
推荐答案
我不认为这是可能的...
i don't think, that is possible ...
localhost:8080/long_polling
是一个URI
...,更确切地说,它应该是http://localhost:8080/long_polling
...在HTTP
中,URI
将被解析为请求/long_polling
并通过以下方式连接到服务器的端口80在本地主机"域中……也就是说,打开到127.0.0.1:80的tcp连接,然后发送
localhost:8080/long_polling
is a URI
... more exactly, it should be http://localhost:8080/long_polling
... in HTTP
the URI
would be resolved as requesting /long_polling
, to port 80 to the server with at the domain 'localhost' ... that is, opening a tcp-connection to 127.0.0.1:80, and sending
GET /long_polling HTTP/1.1
Host: localhost:8080
加上一些其他的HTTP标头...我还没有听说过,可以跨进程绑定端口...
plus some additional HTTP headers ... i haven't heard yet, that ports can be bound accross processes ...
实际上,如果我理解得很好,nginx被设计为可伸缩的代理……而且,他们声称它们需要2.5 MB的内存才能建立10000个HTTP空闲连接……所以这真的不应该成为问题...
actually, if i understand well, nginx was designed to be a scalable proxy ... also, they claim they need 2.5 MB for 10000 HTTP idling connections ... so that really shouldn't be a problem ...
您使用的是哪种彗星服务器?您能否让彗星服务器代理Web服务器?正常的http请求应尽快处理...
what comet server are you using? could you maybe let the comet server proxy a webserver? normal http requests should be handled quickly ...
greetz
back2dos
这篇关于Nginx代理到彗星的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!