SSL Enabling Issues: Django Application on RedHat Linux

Dear Team,

Thanks for the always help me .

I am getting one issues once I enabling the SSL.

Error:

No moudle found **project name **

Logs Details:

[Thu Oct 08 04:06:51.965595 2020] [wsgi:error] [pid 44847:tid 139915017914112] [client 172.30.30.90:62364] ModuleNotFoundError: No module named ‘SELFSERVICES’

[Thu Oct 08 04:06:52.221616 2020] [wsgi:error] [pid 44848:tid 139915017914112] [client 172.30.30.90:62363] mod_wsgi (pid=44848): Failed to exec Python script file ‘/u01/app/python_app/oiccare/django/alshirawicare/SELFSERVICES/wsgi.py’., referer: https://care.alshirawi.ae:9933/

[Thu Oct 08 04:06:52.221698 2020] [wsgi:error] [pid 44848:tid 139915017914112] [client 172.30.30.90:62363] mod_wsgi (pid=44848): Exception occurred processing WSGI script ‘/u01/app/python_app/oiccare/django/alshirawicare/SELFSERVICES/wsgi.py’., referer: https://care.alshirawi.ae:9933/

[Thu Oct 08 04:06:52.222384 2020] [wsgi:error] [pid 44848:tid 139915017914112] [client 172.30.30.90:62363] Traceback (most recent call last):, referer: https://care.alshirawi.ae:9933/

[Thu Oct 08 04:06:52.222467 2020] [wsgi:error] [pid 44848:tid 139915017914112] [client 172.30.30.90:62363] File “/u01/app/python_app/oiccare/django/alshirawicare/SELFSERVICES/wsgi.py”, line 16, in , referer: https://care.alshirawi.ae:9933/

[Thu Oct 08 04:06:52.222478 2020] [wsgi:error] [pid 44848:tid 139915017914112] [client 172.30.30.90:62363] application = get_wsgi_application(), referer: https://care.alshirawi.ae:9933/

[Thu Oct 08 04:06:52.222487 2020] [wsgi:error] [pid 44848:tid 139915017914112] [client 172.30.30.90:62363] File “/u01/app/python_app/oiccare/oiccareapp/lib/python3.6/site-packages/django/core/wsgi.py”, line 12, in get_wsgi_application, referer: https://care.alshirawi.ae:9933/

[Thu Oct 08 04:06:52.222492 2020] [wsgi:error] [pid 44848:tid 139915017914112] [client 172.30.30.90:62363] django.setup(set_prefix=False), referer: https://care.alshirawi.ae:9933/

[Thu Oct 08 04:06:52.222501 2020] [wsgi:error] [pid 44848:tid 139915017914112] [client 172.30.30.90:62363] File “/u01/app/python_app/oiccare/oiccareapp/lib/python3.6/site-packages/django/init.py”, line 19, in setup, referer: https://care.alshirawi.ae:9933/

[Thu Oct 08 04:06:52.222506 2020] [wsgi:error] [pid 44848:tid 139915017914112] [client 172.30.30.90:62363] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING), referer: https://care.alshirawi.ae:9933/

[Thu Oct 08 04:06:52.222513 2020] [wsgi:error] [pid 44848:tid 139915017914112] [client 172.30.30.90:62363] File “/u01/app/python_app/oiccare/oiccareapp/lib/python3.6/site-packages/django/conf/init.py”, line 76, in getattr, referer: https://care.alshirawi.ae:9933/

[Thu Oct 08 04:06:52.222518 2020] [wsgi:error] [pid 44848:tid 139915017914112] [client 172.30.30.90:62363] self._setup(name), referer: https://care.alshirawi.ae:9933/

[Thu Oct 08 04:06:52.222525 2020] [wsgi:error] [pid 44848:tid 139915017914112] [client 172.30.30.90:62363] File “/u01/app/python_app/oiccare/oiccareapp/lib/python3.6/site-packages/django/conf/init.py”, line 63, in _setup, referer: https://care.alshirawi.ae:9933/

[Thu Oct 08 04:06:52.222533 2020] [wsgi:error] [pid 44848:tid 139915017914112] [client 172.30.30.90:62363] self._wrapped = Settings(settings_module), referer: https://care.alshirawi.ae:9933/

[Thu Oct 08 04:06:52.222540 2020] [wsgi:error] [pid 44848:tid 139915017914112] [client 172.30.30.90:62363] File “/u01/app/python_app/oiccare/oiccareapp/lib/python3.6/site-packages/django/conf/init.py”, line 142, in init, referer: https://care.alshirawi.ae:9933/

[Thu Oct 08 04:06:52.222545 2020] [wsgi:error] [pid 44848:tid 139915017914112] [client 172.30.30.90:62363] mod = importlib.import_module(self.SETTINGS_MODULE), referer: https://care.alshirawi.ae:9933/

[Thu Oct 08 04:06:52.222552 2020] [wsgi:error] [pid 44848:tid 139915017914112] [client 172.30.30.90:62363] File “/usr/lib64/python3.6/importlib/init.py”, line 126, in import_module, referer: https://care.alshirawi.ae:9933/

[Thu Oct 08 04:06:52.222558 2020] [wsgi:error] [pid 44848:tid 139915017914112] [client 172.30.30.90:62363] return _bootstrap._gcd_import(name[level:], package, level), referer: https://care.alshirawi.ae:9933/

[Thu Oct 08 04:06:52.222565 2020] [wsgi:error] [pid 44848:tid 139915017914112] [client 172.30.30.90:62363] File “”, line 994, in _gcd_import, referer: https://care.alshirawi.ae:9933/

[Thu Oct 08 04:06:52.222573 2020] [wsgi:error] [pid 44848:tid 139915017914112] [client 172.30.30.90:62363] File “”, line 971, in _find_and_load, referer: https://care.alshirawi.ae:9933/

[Thu Oct 08 04:06:52.222585 2020] [wsgi:error] [pid 44848:tid 139915017914112] [client 172.30.30.90:62363] File “”, line 941, in _find_and_load_unlocked, referer: https://care.alshirawi.ae:9933/

[Thu Oct 08 04:06:52.222592 2020] [wsgi:error] [pid 44848:tid 139915017914112] [client 172.30.30.90:62363] File “”, line 219, in _call_with_frames_removed, referer: https://care.alshirawi.ae:9933/

[Thu Oct 08 04:06:52.222600 2020] [wsgi:error] [pid 44848:tid 139915017914112] [client 172.30.30.90:62363] File “”, line 994, in _gcd_import, referer: https://care.alshirawi.ae:9933/

[Thu Oct 08 04:06:52.222608 2020] [wsgi:error] [pid 44848:tid 139915017914112] [client 172.30.30.90:62363] File “”, line 971, in _find_and_load, referer: https://care.alshirawi.ae:9933/

[Thu Oct 08 04:06:52.222615 2020] [wsgi:error] [pid 44848:tid 139915017914112] [client 172.30.30.90:62363] File “”, line 953, in _find_and_load_unlocked, referer: https://care.alshirawi.ae:9933/

[Thu Oct 08 04:06:52.222635 2020] [wsgi:error] [pid 44848:tid 139915017914112] [client 172.30.30.90:62363] ModuleNotFoundError: No module named ‘SELFSERVICES’, referer: https://care.alshirawi.ae:9933/

I’m guessing from these logs that you’re running this under mod_python within apache. If so, can you post the appropriate sections of your apache conf file(s)?
I’d be looking for both the segment describing your ssl configuration and the segment for running Django.
(If you’re not using apache, how are you running this?)

Correct Sir , I am using apache server.

As advised , please find the below .config file details.


<VirtualHost *:9933>

Alias /static /u01/app/python_app/oiccare/django/alshirawicare/baseapp/static

<Directory /u01/app/python_app/oiccare/django/alshirawicare/baseapp/static>

    Require all granted

</Directory>

<Directory /u01/app/python_app/oiccare/django/alshirawicare>

    <Files wsgi.py>

        Require all granted

    </Files>

</Directory>

WSGIScriptAlias  / /u01/app/python_app/oiccare/django/alshirawicare/SELFSERVICES/wsgi.py

WSGIDaemonProcess *:9933 \

display-name=’(wsgi:*:9933:1000)’ \

home=’/u01/app/python_app/oiccare/django/alshirawicare’ \

processes=1 \

threads=5 \

maximum-requests=0 \

python-path=’/u01/app/python_app/oiccare/oiccareapp/lib64/python3.6/site-packages’ \

python-eggs=’/u01/app/python_app/oiccare/django/alshirawicare/python-eggs’ \

lang=‘en_US.UTF-8’ \

locale=‘en_US.UTF-8’ \

listen-backlog=100 \

queue-timeout=45 \

socket-timeout=60 \

connect-timeout=15 \

request-timeout=60 \

inactivity-timeout=0 \

startup-timeout=15 \

deadlock-timeout=60 \

graceful-timeout=15 \

eviction-timeout=0 \

restart-interval=0 \

cpu-time-limit=0 \

shutdown-timeout=5 \

send-buffer-size=0 \

receive-buffer-size=0 \

header-buffer-size=0 \

response-buffer-size=0 \

response-socket-timeout=0 \

server-metrics=Off

SSLEngine on

SSLCertificateFile /u01/Keystore/star_alshirawi_ae_23325781star_alshirawi_ae.crt

SSLCertificateKeyFile /u01/Keystore/care.key

SSLCertificateChainFile  /u01/Keystore/star_alshirawi_ae_23325781DigiCertCA.crt

CustomLog "logs/selfservice.log" common

this is the Mod_wsgi which is loded from pyhton

Example:

LoadModule foo_module modules/mod_foo.so

LoadModule wsgi_module “/u01/app/python_app/oiccare/oiccareapp/lib64/python3.6/site-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so

LoadModule authn_file_module modules/mod_authn_file.so

While I’m reviewing your configuration, please edit your post with the configuration data by enclosing that data between lines of three backtick - ` characters. You’ll have a line of ```, followed by the file data, followed by another line of ```. This maintains the formatting of the data you’re posting.

Can you confirm that this is the correct directory for that file? (Keep in mind that file and directory names are case sensitive in Linux. A directory named ‘selfservices’ is not the same directory as ‘SELFSERVICES’.)

You’ll also want to confirm that Apache has access to that directory structure.

Also, are you saying that this was working before you enabled SSL on this server? If so, you might want to do a file comparison between the last time it worked and now to verify that you didn’t accidentally introduce a change in the file that is now causing it to fail.

This normally means the path/to/project/dir or path/to/venv isn’t right. i.e. the code just isn’t being found.

The solution there is to just go over everything and double check it’s correct until you find the error. That’s not particularly helpful I know, but it’s quite hard to debug servers from a forum :slight_smile: Good luck!

<VirtualHost *:9933>
Alias /static /u01/app/python_app/oiccare/django/alshirawicare/baseapp/static
<Directory /u01/app/python_app/oiccare/django/alshirawicare/baseapp/static>
Require all granted

<Directory /u01/app/python_app/oiccare/django/alshirawicare>

Require all granted


WSGIScriptAlias / /u01/app/python_app/oiccare/django/alshirawicare/SELFSERVICES/wsgi.py
WSGIDaemonProcess :9933
display-name=’(wsgi:
:9933:1000)’
home=’/u01/app/python_app/oiccare/django/alshirawicare’
processes=1
threads=5
maximum-requests=0
python-path=’/u01/app/python_app/oiccare/oiccareapp/lib64/python3.6/site-packages’
python-eggs=’/u01/app/python_app/oiccare/django/alshirawicare/python-eggs’
lang=‘en_US.UTF-8’
locale=‘en_US.UTF-8’
listen-backlog=100
queue-timeout=45
socket-timeout=60
connect-timeout=15
request-timeout=60
inactivity-timeout=0
startup-timeout=15
deadlock-timeout=60
graceful-timeout=15
eviction-timeout=0
restart-interval=0
cpu-time-limit=0
shutdown-timeout=5
send-buffer-size=0
receive-buffer-size=0
header-buffer-size=0
response-buffer-size=0
response-socket-timeout=0
server-metrics=Off
SSLEngine on
SSLCertificateFile /u01/Keystore/star_alshirawi_ae_23325781star_alshirawi_ae.crt
SSLCertificateKeyFile /u01/Keystore/care.key
SSLCertificateChainFile /u01/Keystore/star_alshirawi_ae_23325781DigiCertCA.crt
CustomLog “logs/selfservice.log” common
<//VirtualHost>

Sir, SELFSERVICES is a project name under SELFSERVICES settings.py and wsgi.py file. So that is capital letter only. Yes without SSL it is working fine after enable the SSL it is not working.

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at you@example.com to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.