Trying to set up flask with nginx and gunicorn
Install Flask: Begin by installing Flask using
pip, Python's package manager.
Create a Flask App: Develop your Flask application by defining routes, views, and functionality.
Install Gunicorn: Use
pipto install Gunicorn, a WSGI HTTP server for Python web applications.
Test Gunicorn with Flask: Check if Gunicorn runs your Flask app properly by using the command
gunicorn app:appin the directory where your Flask app resides.
Configure Nginx: Set up Nginx as a reverse proxy to handle client requests and pass them to Gunicorn. Create an Nginx configuration file for your Flask app.
Start Nginx: Ensure Nginx is running using the command
sudo systemctl start nginx.
Enable Nginx: Enable Nginx to start at boot using
sudo systemctl enable nginx.
Configure Firewall: Adjust the firewall settings to allow traffic on the necessary ports for Nginx and Gunicorn, typically ports 80 and 443.
Test: Access your Flask app in a web browser by entering the server's IP address or domain name. This should now be routed through Nginx and Gunicorn.
Monitor Logs: Check Nginx and Gunicorn logs to troubleshoot any errors or issues that might arise during the setup and operation of your Flask application.