如何为Bokeh Serve配置HTTPS以替代HTTP?
配置Bokeh Serve启用HTTPS的方法
Hey there! Good news—Bokeh Serve supports HTTPS configuration right from the command line, much like Jupyter does. Here's how to set it up for your EC2 Docker environment:
Core Command Line Parameters
Bokeh provides two key flags to enable HTTPS:
--ssl-certfile: Path to your SSL certificate file (in PEM format)--ssl-keyfile: Path to your private key file (in PEM format; required if your cert file doesn't include the private key)
Example Command for Your Setup
Since you already have your certificate at /.keys/mycert.pem, assuming your private key is stored at /.keys/mykey.pem, your launch command would look like this:
bokeh serve --port 8000 --ssl-certfile=/.keys/mycert.pem --ssl-keyfile=/.keys/mykey.pem
If your mycert.pem file already includes the private key (some combined PEM files do), you can simplify it to just:
bokeh serve --port 8000 --ssl-certfile=/.keys/mycert.pem
Important Notes for Your Docker/EC2 Environment
- File Access: Make sure the Docker container can access the certificate files. Either mount the host directory containing your keys into the container (e.g., using
-v /host/path/to/keys:/.keyswhen running the container) or copy the files into the container image during build. - Port & Security Groups: Update your EC2 security group to allow inbound traffic on port 8000 (or switch to the standard HTTPS port 443 for cleaner access—just change
--port 443in the command and map Docker's 443 to the host's 443 with-p 443:443). - Certificate Validity: If you're using a self-signed certificate, browsers will show a security warning. For production use, consider using a CA-signed certificate (like Let's Encrypt).
- Persistent Configuration (Optional): If you prefer not to pass flags every time, create a Bokeh config file (e.g.,
bokeh_config.conf) with these lines:
Then launch Bokeh Serve with:[bokeh] ssl_certfile = /.keys/mycert.pem ssl_keyfile = /.keys/mykey.pembokeh serve --port 8000 --config bokeh_config.conf
That should get your Bokeh Serve running over HTTPS smoothly!
内容的提问来源于stack exchange,提问作者Rutger Hofste
相关产品推荐
相关产品推荐

