SteveLTN / https-portal

A fully automated HTTPS server powered by Nginx, Let's Encrypt and Docker.
MIT License
4.48k stars 297 forks source link

StreamingHttpResponse Not work over https #354

Closed maycuatroi closed 8 months ago

maycuatroi commented 8 months ago

I'm currently facing an issue with using HTTPS with the following configuration:

https-portal:
  image: steveltn/https-portal:1
  ports:
    - "80:80"
    - "443:443"
  environment:
    DOMAINS: 'xxx.xxx.tech -> http://django:8080'
    STAGE: 'production'  # Don't use production until staging works
    FORCE_RENEW: true
    EMAIL: 'xxx@xxx.com'

When sending requests through the server, the Stream Response seems to not work:

return StreamingHttpResponse(
            streaming_content=stream, content_type="text/event-stream"
        ) # not working

However, when I test with the same server, bypassing HTTPS and directly opening the container's django port to send an HTTP request to port 8080, the stream response works fine.

I have limited experience handling Stream Responses with NGINX and would appreciate any guidance.

image

maycuatroi commented 8 months ago
      WEBSOCKET: 'true'
      WORKER_PROCESSES: '10'

-> Not work

maycuatroi commented 8 months ago

Resolved.

We need to update python code in django app

response = StreamingHttpResponse(
            streaming_content=stream, content_type="text/event-stream"
        )
        response["Cache-Control"] = "no-cache" # prevent client cache
        response["X-Accel-Buffering"] = "no" # Allow Stream over NGINX server
        return response