SlideShare a Scribd company logo
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
Jordi Soucheiron
 
PDF
DevOps(3) : Ansible - (MOSG)
Soshi Nemoto
 
PDF
體驗 Hhvm
Chen Cheng-Wei
 
PDF
DevOps Series: Extending vagrant with Puppet for configuration management
Felipe
 
PDF
Provisioning with Puppet
Joe Ray
 
PDF
Instruction: dev environment
Soshi Nemoto
 
PPTX
Vagrant step-by-step guide for Beginners
Sagar Acharya
 
PDF
DevOps(2) : Vagrant - (MOSG)
Soshi Nemoto
 
nginx + uwsgi emperor + bottle
Jordi Soucheiron
 
DevOps(3) : Ansible - (MOSG)
Soshi Nemoto
 
體驗 Hhvm
Chen Cheng-Wei
 
DevOps Series: Extending vagrant with Puppet for configuration management
Felipe
 
Provisioning with Puppet
Joe Ray
 
Instruction: dev environment
Soshi Nemoto
 
Vagrant step-by-step guide for Beginners
Sagar Acharya
 
DevOps(2) : Vagrant - (MOSG)
Soshi Nemoto
 

What's hot (19)

PDF
Create your very own Development Environment with Vagrant and Packer
frastel
 
PDF
Making environment for_infrastructure_as_code
Soshi Nemoto
 
PDF
Docker command
Eric Ahn
 
PDF
Speed up your development environment PHP + Nginx + Fedora + PG
Marcus Sá
 
PPTX
Vagrant
ProfessionalVMware
 
PPTX
6 Years of Docker: The Good, the Bad and Python Packaging at PyCon.DE&PyData ...
Sebastian Neubauer
 
PPT
Node.js Cloud deployment
Nicholas McClay
 
PDF
Docker puppetcamp london 2013
Tomas Doran
 
PPTX
Python+anaconda Development Environment
Kwangyoun Jung
 
PDF
Backing up thousands of containers
Marian Marinov
 
PPTX
Build & test Apache Hawq
PivotalOpenSourceHub
 
PDF
Ondřej Šika: Docker, Traefik a CI - Mějte nasazené všeny větve na kterých pra...
Develcz
 
PDF
Dev ops
Tom Hall
 
PPTX
Dockercon - Building a Chef cookbook testing pipeline with Drone.IO and Docker
pczarkowski
 
PPTX
Docker 101 & Workshop
Elton Stoneman
 
PDF
Cialug August 2021
Andrew Denner
 
PDF
Docker perl build
Workhorse Computing
 
PPTX
Archlinux dev environment
Luke Luo
 
Create your very own Development Environment with Vagrant and Packer
frastel
 
Making environment for_infrastructure_as_code
Soshi Nemoto
 
Docker command
Eric Ahn
 
Speed up your development environment PHP + Nginx + Fedora + PG
Marcus Sá
 
6 Years of Docker: The Good, the Bad and Python Packaging at PyCon.DE&PyData ...
Sebastian Neubauer
 
Node.js Cloud deployment
Nicholas McClay
 
Docker puppetcamp london 2013
Tomas Doran
 
Python+anaconda Development Environment
Kwangyoun Jung
 
Backing up thousands of containers
Marian Marinov
 
Build & test Apache Hawq
PivotalOpenSourceHub
 
Ondřej Šika: Docker, Traefik a CI - Mějte nasazené všeny větve na kterých pra...
Develcz
 
Dev ops
Tom Hall
 
Dockercon - Building a Chef cookbook testing pipeline with Drone.IO and Docker
pczarkowski
 
Docker 101 & Workshop
Elton Stoneman
 
Cialug August 2021
Andrew Denner
 
Docker perl build
Workhorse Computing
 
Archlinux dev environment
Luke Luo
 
Ad

Viewers also liked (10)

PPTX
EuroPython 2014 - How we switched our 800+ projects from Apache to uWSGI
Max Tepkeev
 
PDF
Symantec 2011 CIP Survey Global Results
Symantec
 
PPTX
uWSGI - Swiss army knife for your Python web apps
Tomislav Raseta
 
PPTX
Getting Started with ASP.net Core 1.0
joescars
 
PDF
nginx入門
Takashi Takizawa
 
PPTX
An Introduction to OAuth 2
Aaron Parecki
 
PDF
Scalable Django Architecture
Rami Sayar
 
PPTX
ASP.NET Core 1.0 Overview
Shahed Chowdhuri
 
PDF
Access Control Presentation
Wajahat Rajab
 
PDF
containerd and CRI
Docker, Inc.
 
EuroPython 2014 - How we switched our 800+ projects from Apache to uWSGI
Max Tepkeev
 
Symantec 2011 CIP Survey Global Results
Symantec
 
uWSGI - Swiss army knife for your Python web apps
Tomislav Raseta
 
Getting Started with ASP.net Core 1.0
joescars
 
nginx入門
Takashi Takizawa
 
An Introduction to OAuth 2
Aaron Parecki
 
Scalable Django Architecture
Rami Sayar
 
ASP.NET Core 1.0 Overview
Shahed Chowdhuri
 
Access Control Presentation
Wajahat Rajab
 
containerd and CRI
Docker, Inc.
 
Ad

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

KEY
Plack at YAPC::NA 2010
Tatsuhiko Miyagawa
 
PDF
Apache HTTPD 2.4 - GWO2016
Jim Jagielski
 
PDF
Apache httpd v2.4
Great Wide Open
 
KEY
Plack perl superglue for web frameworks and servers
Tatsuhiko Miyagawa
 
ODP
Chef training - Day3
Andriy Samilyak
 
PPT
How to host an app for $20 in 20min using buildout and hostout
Dylan Jay
 
PDF
ApacheConNA 2015: What's new in Apache httpd 2.4
Jim Jagielski
 
PPTX
Golang 101 for IT-Pros - Cisco Live Orlando 2018 - DEVNET-1808
Cisco DevNet
 
PDF
Plug-ins: Building, Shipping, Storing, and Running - Nandhini Santhanam and T...
Docker, Inc.
 
PDF
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Fabrice Bernhard
 
PDF
Usage Note of SWIG for PHP
William Lee
 
PDF
Learning Docker with Thomas
Thomas Tong, FRM, PMP
 
PDF
Use Xdebug to profile PHP
Seravo
 
PDF
Quick flask an intro to flask
juzten
 
PDF
HTML5 tutorial: canvas, offfline & sockets
Remy Sharp
 
PDF
PSGI REST API
Dovrtel Vaclav
 
PDF
Apigility introduction v2 (glasgow php)
Engineor
 
ODP
When dynamic becomes static : the next step in web caching techniques
Wim Godden
 
PDF
Creating Sentiment Line Chart with Watson
Dev_Events
 
PDF
Testing - Selenium? Rich-Clients? Containers?
Tobias Schneck
 
Plack at YAPC::NA 2010
Tatsuhiko Miyagawa
 
Apache HTTPD 2.4 - GWO2016
Jim Jagielski
 
Apache httpd v2.4
Great Wide Open
 
Plack perl superglue for web frameworks and servers
Tatsuhiko Miyagawa
 
Chef training - Day3
Andriy Samilyak
 
How to host an app for $20 in 20min using buildout and hostout
Dylan Jay
 
ApacheConNA 2015: What's new in Apache httpd 2.4
Jim Jagielski
 
Golang 101 for IT-Pros - Cisco Live Orlando 2018 - DEVNET-1808
Cisco DevNet
 
Plug-ins: Building, Shipping, Storing, and Running - Nandhini Santhanam and T...
Docker, Inc.
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Fabrice Bernhard
 
Usage Note of SWIG for PHP
William Lee
 
Learning Docker with Thomas
Thomas Tong, FRM, PMP
 
Use Xdebug to profile PHP
Seravo
 
Quick flask an intro to flask
juzten
 
HTML5 tutorial: canvas, offfline & sockets
Remy Sharp
 
PSGI REST API
Dovrtel Vaclav
 
Apigility introduction v2 (glasgow php)
Engineor
 
When dynamic becomes static : the next step in web caching techniques
Wim Godden
 
Creating Sentiment Line Chart with Watson
Dev_Events
 
Testing - Selenium? Rich-Clients? Containers?
Tobias Schneck
 

Recently uploaded (20)

PDF
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PDF
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
PDF
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
PDF
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
PPTX
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PDF
Doc9.....................................
SofiaCollazos
 
PDF
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PDF
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
Doc9.....................................
SofiaCollazos
 
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 

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