Simple webapps with nginx, uwsgi emperor and bottle
What is nginx
 HTTP and reverse proxy server
 Event driven

 Very fast
 Easy to configure
What is uWSGI
 WSGI compatible server
 VERY flexible

 Little overhead
 Compatible with many frameworks like: bottle, flask,
django, …
What is bottle
 Bottle is a fast, simple and lightweight WSGI web
microframework
 No additional dependencies
 Uses decorators: @route, @get, @post, etc…
Bottle Hello World
 mkdir –p /opt/uwsgiApps/apps/
 cd /opt/uwsgiApps/apps/

 virtualenv bottle-hello
 cd bottle-hello
 pip install bottle
Bottle Hello World
 vi bottle-hello.py:

from bottle import route, run
@route('/hello')
def hello():
return "Hello World!"
if __name__ == '__main__':
run(port=8080, debug=True)
else:
application = app
Bottle Hello World
 python bottle-hello.py
 Try to access http://localhost:8080/
Bottle Hello World v2
 Add this (after the initial imports) to bottle-hello.py:
from bottle import template
@route('/hello/<name>')
def greet(name='Stranger'):
return template('Hello {{name}}, how are you?', name=name)

 python bottle-hello.py
 Try to access http://localhost:8080/hello/yourname
uWSGI installation
 pip install uwsgi
 vi /etc/init/uwsgi.conf:
# uWSGI - manage uWSGI application server
description "uWSGI Emperor"
start on (filesystem and net-device-up IFACE=lo)
stop on runlevel [!2345]
respawn
env LOGTO=/var/log/uwsgi/uwsgi.log
env BINPATH=/usr/local/bin/uwsgi
exec $BINPATH --emperor /opt/uwsgiApps/conf.d/ --logto $LOGTO
uWSGI emperor
 One of many uWSGI configuration options
 One master process

 Many independent child processes
 Each application has a config file
 Touch or modify the config file to restart the
application
uWSGI example config
 vi /opt/uwsgiapps/conf.d/bottle-hello.xml:

<uwsgi>
<master>true</master>
<processes>1</processes>
<vaccum>true</vaccum>
<chmod-socket>600</chmod-socket>
<socket>/tmp/%n.sock</socket>
<uid>www-data</uid>
<gid>www-data</gid>
<pythonpath>/opt/uwsgiApps/apps/%n/src/</pythonpath>
<module>scatterapp</module>
</uwsgi>
nginx configuration
 vi /etc/nginx/conf.d/subdomain1.domain.com.conf:
server {
listen 80;
server_name subdomain1.domain.com.conf;

location / {
include uwsgi_params;
uwsgi_pass unix://tmp/bottle-example.py;
}
}
System overview


nginx acts as a reverse proxy



nginx redirects the requests based on the domain name or any other
parameter (ip address, url path, cookies, etc)



uWSGI starts and stops the applications



bottle is used to program the application
Questions
Links
 http://nginx.org/
 http://uwsgi-docs.readthedocs.org/

 http://bottlepy.org/

More Related Content

PPTX
nginx + uwsgi emperor + bottle
PDF
DevOps(3) : Ansible - (MOSG)
PDF
體驗 Hhvm
PDF
DevOps Series: Extending vagrant with Puppet for configuration management
PDF
Provisioning with Puppet
PDF
Instruction: dev environment
PPTX
Vagrant step-by-step guide for Beginners
PDF
DevOps(2) : Vagrant - (MOSG)
nginx + uwsgi emperor + bottle
DevOps(3) : Ansible - (MOSG)
體驗 Hhvm
DevOps Series: Extending vagrant with Puppet for configuration management
Provisioning with Puppet
Instruction: dev environment
Vagrant step-by-step guide for Beginners
DevOps(2) : Vagrant - (MOSG)

What's hot (19)

PDF
Create your very own Development Environment with Vagrant and Packer
PDF
Making environment for_infrastructure_as_code
PDF
Docker command
PDF
Speed up your development environment PHP + Nginx + Fedora + PG
PPTX
PPTX
6 Years of Docker: The Good, the Bad and Python Packaging at PyCon.DE&PyData ...
PPT
Node.js Cloud deployment
PDF
Docker puppetcamp london 2013
PPTX
Python+anaconda Development Environment
PDF
Backing up thousands of containers
PPTX
Build & test Apache Hawq
PDF
Ondřej Šika: Docker, Traefik a CI - Mějte nasazené všeny větve na kterých pra...
PDF
Dev ops
PPTX
Dockercon - Building a Chef cookbook testing pipeline with Drone.IO and Docker
PPTX
Docker 101 & Workshop
PDF
Cialug August 2021
PDF
Docker perl build
PPTX
Archlinux dev environment
Create your very own Development Environment with Vagrant and Packer
Making environment for_infrastructure_as_code
Docker command
Speed up your development environment PHP + Nginx + Fedora + PG
6 Years of Docker: The Good, the Bad and Python Packaging at PyCon.DE&PyData ...
Node.js Cloud deployment
Docker puppetcamp london 2013
Python+anaconda Development Environment
Backing up thousands of containers
Build & test Apache Hawq
Ondřej Šika: Docker, Traefik a CI - Mějte nasazené všeny větve na kterých pra...
Dev ops
Dockercon - Building a Chef cookbook testing pipeline with Drone.IO and Docker
Docker 101 & Workshop
Cialug August 2021
Docker perl build
Archlinux dev environment
Ad

Viewers also liked (10)

PPTX
EuroPython 2014 - How we switched our 800+ projects from Apache to uWSGI
PDF
Symantec 2011 CIP Survey Global Results
PPTX
uWSGI - Swiss army knife for your Python web apps
PPTX
Getting Started with ASP.net Core 1.0
PDF
nginx入門
PPTX
An Introduction to OAuth 2
PDF
Scalable Django Architecture
PPTX
ASP.NET Core 1.0 Overview
PDF
Access Control Presentation
PDF
containerd and CRI
EuroPython 2014 - How we switched our 800+ projects from Apache to uWSGI
Symantec 2011 CIP Survey Global Results
uWSGI - Swiss army knife for your Python web apps
Getting Started with ASP.net Core 1.0
nginx入門
An Introduction to OAuth 2
Scalable Django Architecture
ASP.NET Core 1.0 Overview
Access Control Presentation
containerd and CRI
Ad

Similar to Simple webapps with nginx, uwsgi emperor and bottle (20)

PPTX
Nginx-deploy on linux server with 80 and 442
PDF
Free django
PPTX
Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...
PDF
Guideline paper@rpi full_stack_python_arch
PDF
ITB2019 NGINX Overview and Technical Aspects - Kevin Jones
KEY
The story and tech of Read the Docs
PDF
Batteries not included
PPTX
NGINX: Basics & Best Practices - EMEA Broadcast
PDF
WSGI, Django, Gunicorn
PDF
What The Flask? and how to use it with some Google APIs
PPTX
flask frameworkbasedonPython_microframework.pptx
PDF
Behind the curtain - How Django handles a request
PDF
App Engine
PDF
NGINX: Basics and Best Practices EMEA
PPTX
Python Code Camp for Professionals 2/4
PPTX
PDF
Flask Introduction - Python Meetup
PDF
CollegeDiveIn presentation
PDF
Django for mobile applications
KEY
Nginx - Tips and Tricks.
Nginx-deploy on linux server with 80 and 442
Free django
Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...
Guideline paper@rpi full_stack_python_arch
ITB2019 NGINX Overview and Technical Aspects - Kevin Jones
The story and tech of Read the Docs
Batteries not included
NGINX: Basics & Best Practices - EMEA Broadcast
WSGI, Django, Gunicorn
What The Flask? and how to use it with some Google APIs
flask frameworkbasedonPython_microframework.pptx
Behind the curtain - How Django handles a request
App Engine
NGINX: Basics and Best Practices EMEA
Python Code Camp for Professionals 2/4
Flask Introduction - Python Meetup
CollegeDiveIn presentation
Django for mobile applications
Nginx - Tips and Tricks.

Recently uploaded (20)

PDF
Co-training pseudo-labeling for text classification with support vector machi...
PPTX
Internet of Everything -Basic concepts details
PDF
IT-ITes Industry bjjbnkmkhkhknbmhkhmjhjkhj
PDF
CEH Module 2 Footprinting CEH V13, concepts
PDF
Ensemble model-based arrhythmia classification with local interpretable model...
PDF
Human Computer Interaction Miterm Lesson
PDF
Advancing precision in air quality forecasting through machine learning integ...
PDF
giants, standing on the shoulders of - by Daniel Stenberg
PDF
Planning-an-Audit-A-How-To-Guide-Checklist-WP.pdf
PDF
Rapid Prototyping: A lecture on prototyping techniques for interface design
PDF
“The Future of Visual AI: Efficient Multimodal Intelligence,” a Keynote Prese...
PDF
Transform-Your-Supply-Chain-with-AI-Driven-Quality-Engineering.pdf
PDF
A symptom-driven medical diagnosis support model based on machine learning te...
PDF
MENA-ECEONOMIC-CONTEXT-VC MENA-ECEONOMIC
PDF
4 layer Arch & Reference Arch of IoT.pdf
PDF
AI.gov: A Trojan Horse in the Age of Artificial Intelligence
PDF
NewMind AI Weekly Chronicles – August ’25 Week IV
PDF
The-2025-Engineering-Revolution-AI-Quality-and-DevOps-Convergence.pdf
PDF
Examining Bias in AI Generated News Content.pdf
PDF
LMS bot: enhanced learning management systems for improved student learning e...
Co-training pseudo-labeling for text classification with support vector machi...
Internet of Everything -Basic concepts details
IT-ITes Industry bjjbnkmkhkhknbmhkhmjhjkhj
CEH Module 2 Footprinting CEH V13, concepts
Ensemble model-based arrhythmia classification with local interpretable model...
Human Computer Interaction Miterm Lesson
Advancing precision in air quality forecasting through machine learning integ...
giants, standing on the shoulders of - by Daniel Stenberg
Planning-an-Audit-A-How-To-Guide-Checklist-WP.pdf
Rapid Prototyping: A lecture on prototyping techniques for interface design
“The Future of Visual AI: Efficient Multimodal Intelligence,” a Keynote Prese...
Transform-Your-Supply-Chain-with-AI-Driven-Quality-Engineering.pdf
A symptom-driven medical diagnosis support model based on machine learning te...
MENA-ECEONOMIC-CONTEXT-VC MENA-ECEONOMIC
4 layer Arch & Reference Arch of IoT.pdf
AI.gov: A Trojan Horse in the Age of Artificial Intelligence
NewMind AI Weekly Chronicles – August ’25 Week IV
The-2025-Engineering-Revolution-AI-Quality-and-DevOps-Convergence.pdf
Examining Bias in AI Generated News Content.pdf
LMS bot: enhanced learning management systems for improved student learning e...

Simple webapps with nginx, uwsgi emperor and bottle

  • 2. What is nginx  HTTP and reverse proxy server  Event driven  Very fast  Easy to configure
  • 3. What is uWSGI  WSGI compatible server  VERY flexible  Little overhead  Compatible with many frameworks like: bottle, flask, django, …
  • 4. What is bottle  Bottle is a fast, simple and lightweight WSGI web microframework  No additional dependencies  Uses decorators: @route, @get, @post, etc…
  • 5. Bottle Hello World  mkdir –p /opt/uwsgiApps/apps/  cd /opt/uwsgiApps/apps/  virtualenv bottle-hello  cd bottle-hello  pip install bottle
  • 6. Bottle Hello World  vi bottle-hello.py: from bottle import route, run @route('/hello') def hello(): return "Hello World!" if __name__ == '__main__': run(port=8080, debug=True) else: application = app
  • 7. Bottle Hello World  python bottle-hello.py  Try to access http://localhost:8080/
  • 8. Bottle Hello World v2  Add this (after the initial imports) to bottle-hello.py: from bottle import template @route('/hello/<name>') def greet(name='Stranger'): return template('Hello {{name}}, how are you?', name=name)  python bottle-hello.py  Try to access http://localhost:8080/hello/yourname
  • 9. uWSGI installation  pip install uwsgi  vi /etc/init/uwsgi.conf: # uWSGI - manage uWSGI application server description "uWSGI Emperor" start on (filesystem and net-device-up IFACE=lo) stop on runlevel [!2345] respawn env LOGTO=/var/log/uwsgi/uwsgi.log env BINPATH=/usr/local/bin/uwsgi exec $BINPATH --emperor /opt/uwsgiApps/conf.d/ --logto $LOGTO
  • 10. uWSGI emperor  One of many uWSGI configuration options  One master process  Many independent child processes  Each application has a config file  Touch or modify the config file to restart the application
  • 11. uWSGI example config  vi /opt/uwsgiapps/conf.d/bottle-hello.xml: <uwsgi> <master>true</master> <processes>1</processes> <vaccum>true</vaccum> <chmod-socket>600</chmod-socket> <socket>/tmp/%n.sock</socket> <uid>www-data</uid> <gid>www-data</gid> <pythonpath>/opt/uwsgiApps/apps/%n/src/</pythonpath> <module>scatterapp</module> </uwsgi>
  • 12. nginx configuration  vi /etc/nginx/conf.d/subdomain1.domain.com.conf: server { listen 80; server_name subdomain1.domain.com.conf; location / { include uwsgi_params; uwsgi_pass unix://tmp/bottle-example.py; } }
  • 13. System overview  nginx acts as a reverse proxy  nginx redirects the requests based on the domain name or any other parameter (ip address, url path, cookies, etc)  uWSGI starts and stops the applications  bottle is used to program the application