Koozali.org formerly Contribs.org

How to deploy a Flask web service for production on SME 9.2,Apache and mod_wsgi?

Hi All,

I have deployed a Flask web service on SME 9.2, and I am able to run the service using the built-in Flask web server, and it works as expected.  Now for production, I need to deploy the web service on Apache and use mod_wsgi as the gateway.  I am confused as to how to do this.  I know that I will need to create a custom template for Apache to know about my Flask web service.  I'm not sure what that file would look like as far as the content.  Do I define <location> or <virtualhost>.  Has anyone deployed a Flask app or web service on Apache/mod_wsgi for production on SME 9.2?

Thank you for any assistance!

Sara
« Last Edit: August 31, 2019, 03:48:25 AM by swatson »

Offline ReetP

  • *
  • 2,110
Search & read the wiki.

This may help.

https://wiki.contribs.org/Webapps-common

To.do it manually check these.

https://wiki.contribs.org/SME_Server:Documentation:ProxyPass

Particularly read about 'TemplatePath'

I really must write a bit more on it.

If you set it you can create your own virtual host section with templates in:

/etc/e-smith/templates/etc/httpd/httpd.conf/myVirtualHostTemplatePath.

See how webapps does it.

The Rocket.Chat contrib does it so it wasn't reliant on webapps. Check the source.
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Thank you for your response.  I will take a look.

...for production, I need to deploy the web service on Apache and use mod_wsgi as the gateway.  I am confused as to how to do this.  I know that I will need to create a custom template for Apache to know about my Flask web service.  I'm not sure what that file would look like as far as the content.  Do I define <location> or <virtualhost>.  Has anyone deployed a Flask app or web service on Apache/mod_wsgi for production on SME 9.2

Thanks for chatting with me about this. To recap our conversation...
First, make certain the mod_wsgi.so is installed on the system. Yum can be used for this.
Second, create a custom template to load the mod_wsgi.so in Apache. This is a file that contains an Apache LoadModule directive. See the koozali docs as well as the Apache docs.
Finally, create a custom template to define an Apache Location. A location is part of a URL, such as a location “/status” that appears in a fully formed URL. E.g. www.mydomain/status?p=now.

The Flask docs should contain examples of the details for telling Apache how to communicate with the Flask app via wsgi, which can then be adapted to the template system.
- Mark