python on nginx

    • OMV 4.x
    • python on nginx


      I have install nginx on my OMV4 and normally.
      i have a python program create by flask(on Visual Basic) running on my windows apache, and want to move it to my OMV
      Many try and error, i can run flask on activate virtualenv only
      i find lot of document for wsgi config ,flask/nginx on debian etc....but finally not work. ;(

      it is probable running flask or python thougth Nginx on OMV and any easy way to do that? Thank you for help
    • Hi- yes there is! I happen to be doing this right now! I'm testing this on OMV4 on RPi, and will redo it on my "production" OMV: Odroid XU4, all running Armbian/Debian 9. What's your OMV architecture?

      There seems to be a couple of ways to do it: A new "location" on the "/etc/nginx/sites-available/openmediavault-webgui" or (what I'll be doing, to keep things cleaner) create another "site", with a different port number, in this directory and symbolically linking to the "/etc/nginx/sites-enabled" directory.

      I found this very helpful:…wsgi-for-flask-on-ubuntu/

      I basically followed the full script, using "uwsgi" in Emperor mode too. My Flask app is a RESTful API feeding a MySQL database. All of it will be on the OMV box.

      I got the full stack working on a copy of Raspbian, now to OMV.

      Hope this helps.

    • Hi Peter,

      Tks for your reply ,refer to your tutorial, i can run my flask under activating virtualenv and using python
      uwsgi --socket --protocol=http -w wsgi:app, it also work.

      However, cannot run it by run by a service / on Ngnix.

      It return 502 Bad Gateway but
      display Active: active (running) on screen

      Not very understand what is the problem
      Still working hard to fix it out

      The post was edited 1 time, last by singwong28 ().

    • Hi
      I got stuck on that too initially and spent a bit of time figuring it out. In the end, it's quite straightforward:

      The "-w run:app" is the same as "module=run:app" when you use the Vassal ini file in /etc/uwsgi/vassals/<app_name>.ini.

      So, the flask python app you've created will have a name eg; In this '' script, there should be a line that reads like: 'app = Flask(__name__)'.

      Running the 'uwsgi --socket --protocol=http -w run:app' will start uwsgi on the localhost, listening on Port 8080, running your Python application called '', referencing the 'app' line inside your application.

      This may help:…an1/uwsgi_python27.1.html

      Looks like you're very close to getting it working.