I have a Virtual server running Ubuntu 22.04. Nginx is already installed. I have created two separate directories for my Flask apps. The structure for Flask app 1 is: /home/myname/creative_space/ inside that directory I have created a venv and activated it so I could install via pip Gunicorn, Flask, Flask_bootstrap. Also in this directory is app.py, a 'static' directory, a 'templates' directory and a wsgi.py file. This structure has been duplicated for the 2nd Flask app and is here: /home/myname/annsquared
The virtual server has assigned an IP of 192.168.50.192 Both sites can be accessed by doing the following: Flask app 1 is 192.168.50.192:8000 and the second Flask app 2 is 192.168.50.192:8001 Additionally I created two files in /etc/nginx/sites-available/ the files are named 'creative_space' and the other 'annsquared'
The contents for creative_space is as follows:
server {
listen 80;
server_name 192.168.50.192;
location / {
proxy_pass http://127.0.0.1:8000/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
The contents for annsquared is as follows:
server {
listen 80;
server_name 192.168.50.192;
location /annsquared {
proxy_pass http://127.0.0.1:8001/annsquared;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
location /static/ {
root /home/myname/annsquared/static/;
expires 30d;
}
}
Both files are linked to sites-enabled.
Also I created two files in /etc/systemd/system the files are named 'creative_space.service' and the other 'annsquared.service'
The content for creative_space.service is as follows:
[Unit]
Description=Gunicorn instance for a Flask app
After=network.target
[Service]
User=myname
Group=www-data
WorkingDirectory=/home/myname/creative_space
Environment="PATH=/home/myname/creative_space/venv/bin"
ExecStart=/home/myname/creative_space/venv/bin/gunicorn --workers 3 --bind 0.0.0.0:8000 --error-logfile /var/log/creative_space/error.log wsgi:app
[Install]
WantedBy=multi-user.target
The content for annquared.service is as follows:
[Unit]
Description=Gunicorn instance to serve annsquared
After=network.target
[Service]
User=myname
Group=www-data
WorkingDirectory=/home/myname/annsquared
Environment="PATH=/home/myname/annsquared/venv/bin"
ExecStart= /home/myname/annsquared/venv/bin/gunicorn --workers 3 --bind 0.0.0.0:8001 --error-logfile /var/log/annsquared/error.log wsgi:app
[Install]
WantedBy=multi-user.target
Everything works fine and can be accessed at 192.168.50.192:8000 and 192.168.50.192:8001
What I'm trying to achieve is that the first Flask app (192.168.50.192:8000) can be the root reached at 192.168.50.192 and the second Flask app (192.168.50.192:8001) can be reached at 192.168.50.192/annsquared.
Apologizes for the length of this post but giving the most details upfront usually eliminates a lot of back and forth. Thanks in advance for your guidance!
I have deleted the 'default' file in sites-available and in sites-enabled but still getting the 'Welcome to Nginx' greeter at 192.168.50.192