Trying to set up flask with nginx and gunicorn

  1. Install Flask: Begin by installing Flask using pip, Python's package manager.

  2. Create a Flask App: Develop your Flask application by defining routes, views, and functionality.

  3. Install Gunicorn: Use pip to install Gunicorn, a WSGI HTTP server for Python web applications.

  4. Test Gunicorn with Flask: Check if Gunicorn runs your Flask app properly by using the command gunicorn app:app in the directory where your Flask app resides.

  5. 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.

  6. Start Nginx: Ensure Nginx is running using the command sudo systemctl start nginx.

  7. Enable Nginx: Enable Nginx to start at boot using sudo systemctl enable nginx.

  8. Configure Firewall: Adjust the firewall settings to allow traffic on the necessary ports for Nginx and Gunicorn, typically ports 80 and 443.

  9. 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.

  10. 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.