简体   繁体   中英

Event streams with nginx over tls

I made a php event streaming script that worked perfectly fine when nginx had not tls (ssl) enabled but after enabling tls the request to the event stream stay pending. I tried disabling ssl cache, proxy cache ([here][1] is my website configuration file) but I'm still very new to nginx. I also set the header "X-Accel-Buffering: no" in my php script but with no result. Also, here is my ngninx conf file . Am i missing a line in my config?

Thanks. [1]: https://pastebin.com/a2NutTUA

server {
    listen 8943 default_server ssl;
    listen [::]:8943 default_server ssl;
    ssl on;
    ssl_certificate     /etc/letsencrypt/live/REDACTED-0001/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/REDACTED-0001/privkey.pem;
    ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers         HIGH:!aNULL:!MD5;
    ssl_buffer_size 0;
    root /var/www/nginxlive;
    index index.html index.htm index.nginx-debian.html index.php;
    server_name localhost;
    proxy_set_header Connection '';
    proxy_http_version 1.1;
    chunked_transfer_encoding off;
    proxy_buffering off;
    proxy_cache off;
    proxy_buffer_size 0;

    location / {
            try_files $uri $uri/ =404;
    }
    location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
    }
}
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
    worker_connections 768;
    multi_accept on;
}
 
http {
ssl_session_cache   shared:SSL:10m;
ssl_session_timeout 10m;
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    include /etc/nginx/mime.types;
    default_type application/octet-stream;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;
    gzip off;
    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

Just had the same problem as you and got inspired to use

proxy_buffering off;

Using this flag along with the minimal proxy configuration worked for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM