I'm using Bottle as my webservice. Currently, its running on bottle's default wsgi server and handles HTTP requests. I want to encrypt my webservice and handle HTTPS requests. Can someone suggest a method for this. I tried running on cherrypy server, but the latest version is not supporting the pyOpenSSLAdapter.
As you know bottle also supports Gunicorn. You can find SSL information at
Code example
import bottle
from bottle import Bottle
BASE = Bottle()
@BASE.route('/', ['GET'])
def index():
return 'Index'
bottle.run(
app=BASE,
host='0.0.0.0',
port='8888',
server='gunicorn',
reloader=1,
debug=1,
keyfile='key.pem',
certfile='cert.pem'
)
gunicorn
advantages? Does it automatically start many processes or threads? Or is it mono-threaded, like wsgirefserver (IIRC)? –
Walworth Quick way of achieving https through nginx reverse proxy:-
apt install nginx
Edit /etc/nginx/sites-enabled/default:-
server {
listen 80 default_server; #listen on port 80
listen [::]:80 default_server ipv6only=on;
server_name yourdomain.com www.yourdomain.com; #edit 'yourdomain' with your domain name
root /var/www/html/; #edit to match wherever your bottle-py root folder is
location / {
proxy_pass http://127.0.0.1:8080/;
#assuming configuration of bottle-py run() command is 127.0.0.1:8080
}
}
HTTPS with certbot:-
Login to your domain name provider for 'yourdomain.com' and point 'A-records' to point to your server IP.
apt install certbot python-certbot-nginx
sudo certbot --nginx
Follow the on terminal instructions for certbot. Now bottle-py is served with https by a nginx reverse proxy.
Check https://yourdomain.com and confirm https valid certificate installation.
This is a quick way of doing it. Read more at nginx and certbot documentation.
apt install certbot python3-certbot-nginx
refLink –
Fishwife You need to put your WSGI server (not WsgiRef certainly) behind a reverse-proxy with https support. Nginx is the most common choice.
© 2022 - 2024 — McMap. All rights reserved.
pip install gunicorn
I still had:ModuleNotFoundError: No module named 'fcntl'
and fcntl seems unavailable on Windows: #45228895. – Walworth