2

aws インスタンスで django-sse を動作させようとしています。開発のために、私の django は localhost:8000 で実行され、EventSource はこの localhost:8000/stream1/?lastEventId=&r=5546342101865558 のようなものを指しています。私はすぐにイベントを受け取ります。

この投稿EventSource / Server-Sent Events through Nginxに続いて、本番環境でこの構成を試しました:

upstream message_upstream {
server 54.216.184.203:443;
}

server {
listen 80;
server_name ${cfg:domain_list} ${cfg:redirect_domain_list};
rewrite ^ https://${cfg:domain}$request_uri? permanent;
}

server {
listen 443 ssl;
server_name ${cfg:domain_list};
access_log /var/log/nginx/${cfg:domain_slug}.access.log;

root ${buildout:directory}/public_html;

ssl on;
ssl_certificate /etc/ssl/certs/.... ;
ssl_certificate_key /etc/ssl/certs/......;

location / {
include uwsgi_params;
uwsgi_pass unix:///tmp/${cfg:domain_slug}.sock;
}

location /media {

}

location /static {

}

location ~ ^/stream1 {
proxy_pass https://message_upstream;
proxy_buffering off;
proxy_cache off;
proxy_set_header Host $host;

proxy_set_header Connection '';
proxy_http_version 1.1;
chunked_transfer_encoding off;
}
}

SSL を使用すると、私の構成は、stackoverflow の投稿に記載されているものとは異なります。Amazon コンソールのモニターには、大量のトラフィックが表示されます。そしてnginxログで私は得る:

2013/08/16 06:00:18 [error] 25173#0: *6473 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 54.216.184.203, server: nachhilfe.impac.ch, request: "GET /stream1/?lastEventId=&r=4599838461726904 HTTP/1.1", upstream: "https://54.216.184.203:443/stream1/?lastEventId=&r=4599838461726904", host: "nachhilfe.impac.ch", referrer: "https://nachhilfe.impac.ch/user/1/"

サイトの残りの部分は正しく実行されており、私のマシンで述べたように、sse 部分は機能しています。

私は何が欠けていますか?

4

1 に答える 1

0

これをサーバーに追加してみてください:

http2_max_field_size 64k;
http2_max_header_size 512k;

これをあなたの場所に:

proxy_read_timeout 12h;

これらは、sse接続のタイムアウトと再接続を解決しました。

于 2020-12-08T21:00:35.703 に答える