I’ve deployed several web sites to hosting services over the years but it’s been a while since I’ve deployed them locally. New technologies have come about and I wanted to make sure I don’t get left behind. I picked NGINX and Waitress based on reviews praising their ease-of-use and versatility.

The web application needs to run as a service that Nginx will send traffic to. That’s one of the key things to remember. The application doesn’t run inside Nginx. Makes the flow of traffic easier to visualize. A request gets to the server on port 80. The request gets redirected to Nginx. Based on filters such as the URL, it gets directed to the service. The service generates a response and sends it back. This is how a single web server can host multiple web sites. Similar to NAT.

enable systemd on ubuntu wsl

sudo vi /etc/wsl.conf

wsl.conf contents


create service that starts the waitress server

sudo vi /etc/systemd/system/<application name>.service

contents of .service file

Description=<application description>

WorkingDirectory=<app location>
ExecStart=<waitress-serve command>

Description=Car Maintenance Flask application

ExecStart=/home/carlo/projects/car-maintenance/.venv/bin/waitress-serve --host --port 8000 app:app


if app is stored in a variable waitress-serve --host hello:app

if app is returned by a function waitress-serve --host --call hello:create_app

start the service

sudo systemctl start <application name>.service

if you want it to start automatically

sudo systemctl enable <application name>.service

configure nginx

sudo vi /etc/nginx/sites-enabled/default

contents of config file

server {
	listen 80 default_server; 
	listen [::]:80 default_server;

	server_name _;
	location /static/ {
		alias /home/carlo/projects/car-maintenance/static/;

	location / {
		proxy_pass http://localhost:8000; 
		include /etc/nginx/proxy_params;
		proxy_redirect off; 
		proxy_set_header X-Real-IP $remote_addr;

Add the nginx user to the group that owns the static files

sudo usermod -a -G carlo www-data

Restart nginx and the application service

sudo nginx -s reload

sudo systemctl restart <application name>.service