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)

KEY
Plack at YAPC::NA 2010
PDF
Apache HTTPD 2.4 - GWO2016
PDF
Apache httpd v2.4
KEY
Plack perl superglue for web frameworks and servers
ODP
Chef training - Day3
PPT
How to host an app for $20 in 20min using buildout and hostout
PDF
ApacheConNA 2015: What's new in Apache httpd 2.4
PPTX
Golang 101 for IT-Pros - Cisco Live Orlando 2018 - DEVNET-1808
PDF
Plug-ins: Building, Shipping, Storing, and Running - Nandhini Santhanam and T...
PDF
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
PDF
Usage Note of SWIG for PHP
PDF
Learning Docker with Thomas
PDF
Use Xdebug to profile PHP
PDF
Quick flask an intro to flask
PDF
HTML5 tutorial: canvas, offfline & sockets
PDF
PSGI REST API
PDF
Apigility introduction v2 (glasgow php)
ODP
When dynamic becomes static : the next step in web caching techniques
PDF
Creating Sentiment Line Chart with Watson
PDF
Testing - Selenium? Rich-Clients? Containers?
Plack at YAPC::NA 2010
Apache HTTPD 2.4 - GWO2016
Apache httpd v2.4
Plack perl superglue for web frameworks and servers
Chef training - Day3
How to host an app for $20 in 20min using buildout and hostout
ApacheConNA 2015: What's new in Apache httpd 2.4
Golang 101 for IT-Pros - Cisco Live Orlando 2018 - DEVNET-1808
Plug-ins: Building, Shipping, Storing, and Running - Nandhini Santhanam and T...
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Usage Note of SWIG for PHP
Learning Docker with Thomas
Use Xdebug to profile PHP
Quick flask an intro to flask
HTML5 tutorial: canvas, offfline & sockets
PSGI REST API
Apigility introduction v2 (glasgow php)
When dynamic becomes static : the next step in web caching techniques
Creating Sentiment Line Chart with Watson
Testing - Selenium? Rich-Clients? Containers?

Recently uploaded (20)

PPT
Geologic Time for studying geology for geologist
PDF
Five Habits of High-Impact Board Members
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
PDF
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
PDF
Credit Without Borders: AI and Financial Inclusion in Bangladesh
PPTX
Microsoft Excel 365/2024 Beginner's training
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PDF
The influence of sentiment analysis in enhancing early warning system model f...
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PDF
Convolutional neural network based encoder-decoder for efficient real-time ob...
PPTX
TEXTILE technology diploma scope and career opportunities
PPTX
Module 1 Introduction to Web Programming .pptx
PDF
Improvisation in detection of pomegranate leaf disease using transfer learni...
PDF
Architecture types and enterprise applications.pdf
PDF
Accessing-Finance-in-Jordan-MENA 2024 2025.pdf
PPTX
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
PPTX
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
PDF
sbt 2.0: go big (Scala Days 2025 edition)
PDF
sustainability-14-14877-v2.pddhzftheheeeee
PPT
Module 1.ppt Iot fundamentals and Architecture
Geologic Time for studying geology for geologist
Five Habits of High-Impact Board Members
A contest of sentiment analysis: k-nearest neighbor versus neural network
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
Credit Without Borders: AI and Financial Inclusion in Bangladesh
Microsoft Excel 365/2024 Beginner's training
NewMind AI Weekly Chronicles – August ’25 Week III
The influence of sentiment analysis in enhancing early warning system model f...
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
Convolutional neural network based encoder-decoder for efficient real-time ob...
TEXTILE technology diploma scope and career opportunities
Module 1 Introduction to Web Programming .pptx
Improvisation in detection of pomegranate leaf disease using transfer learni...
Architecture types and enterprise applications.pdf
Accessing-Finance-in-Jordan-MENA 2024 2025.pdf
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
sbt 2.0: go big (Scala Days 2025 edition)
sustainability-14-14877-v2.pddhzftheheeeee
Module 1.ppt Iot fundamentals and Architecture

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