Reputation: 1085
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.
Upvotes: 9
Views: 7470
Reputation: 764
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'
)
Upvotes: 10
Reputation: 65
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.
Upvotes: 4
Reputation: 1564
You need to put your WSGI server (not WsgiRef certainly) behind a reverse-proxy with https support. Nginx is the most common choice.
Upvotes: 2