0

I have created an API using Apche2 mod_wsgi Flask. The API has python & shell script components. The initial version of the API was HTTP, but now I have added HTTPS support as well.

When I am hitting the API via HTTP (http://myapi.mydomain.com/app/apiEndPOint), everything works smoothly. Here pwd command returns /var/www as the present working directory. But when I hit the API via HTTPS (https://myapi.mydomain.com/app/apiEndPOint), it couldn't find different modules (hence it throws errors) because of pwd command returns / as the present working directory.

Why is this happening? I faced the similar problem with python (os.getcwd()) but solved it using an alternate method. But the pwd command problem I couldn't solve.

Any clues/solutions to this problem?

AKA
  • 5,479
  • 4
  • 22
  • 36
  • 1
    You should not rely on the current working directory being a specific directory in applications hosted in a web server. Calculate your paths as an absolute path when you need to refer to anything in the file system. See http://modwsgi.readthedocs.io/en/develop/user-guides/application-issues.html#application-working-directory – Graham Dumpleton Jun 23 '18 at 09:46
  • BTW, you should show you mod_wsgi configuration for both HTTP and HTTPS ``VirtualHost``, as the fact they are different possibly means you haven't set them in a way that agrees. For WSGI applications which use HTTP and HTTPS, you should use a common mod_wsgi daemon process group, which each ``VirtualHost`` is set up to use. – Graham Dumpleton Jun 23 '18 at 09:50

0 Answers0