1

I am getting following error in the production environment with SSL enabled.

ssl_error_log:

[Wed Nov 18 11:14:16.303520 2015] [:error] [pid 14069] [remote 128.132.66.000:116] mod_wsgi (pid=14069): Target WSGI script '/apps/staging/wisdmepid/django_version/django_version/wsgi.py' cannot be loaded as Python module.[Wed Nov 18 11:14:16.303584 2015] [:error] [pid 14069] [remote 128.132.66.000:116] mod_wsgi (pid=14069): Exception occurred processing WSGI script '/apps/staging/wisdmepid/django_version/django_version/wsgi.py'.
[Wed Nov 18 11:14:16.303617 2015] [:error] [pid 14069] [remote 128.132.66.000:116] Traceback (most recent call last):
[Wed Nov 18 11:14:16.303641 2015] [:error] [pid 14069] [remote 128.132.66.000:116]   File "/apps/staging/wisdmepid/django_version/django_version/wsgi.py", line 18, in <module>
[Wed Nov 18 11:14:16.303732 2015] [:error] [pid 14069] [remote 128.132.66.000:116]     application = get_wsgi_application()[Wed Nov 18 11:14:16.303747 2015] [:error] [pid 14069] [remote 128.132.66.000:116]   File "/apps/staging/wisdmepid/django_version/env/lib/python2.7/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
[Wed Nov 18 11:14:16.303805 2015] [:error] [pid 14069] [remote 128.132.66.000:116]     django.setup()
[Wed Nov 18 11:14:16.303816 2015] [:error] [pid 14069] [remote 128.132.66.000:116]   File "/apps/staging/wisdmepid/django_version/env/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
[Wed Nov 18 11:14:16.303861 2015] [:error] [pid 14069] [remote 128.132.66.000:116]     apps.populate(settings.INSTALLED_APPS)
[Wed Nov 18 11:14:16.303870 2015] [:error] [pid 14069] [remote 128.132.66.000:116]   File "/apps/staging/wisdmepid/django_version/env/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
[Wed Nov 18 11:14:16.304015 2015] [:error] [pid 14069] [remote 128.132.66.000:116]     app_config = AppConfig.create(entry)
[Wed Nov 18 11:14:16.304031 2015] [:error] [pid 14069] [remote 128.132.66.000:116]   File "/apps/staging/wisdmepid/django_version/env/lib/python2.7/site-packages/django/apps/config.py", line 86, in create[Wed Nov 18 11:14:16.304125 2015] [:error] [pid 14069] [remote 128.132.66.000:116]     module = import_module(entry)
[Wed Nov 18 11:14:16.304136 2015] [:error] [pid 14069] [remote 128.132.66.000:116]   File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
[Wed Nov 18 11:14:16.304199 2015] [:error] [pid 14069] [remote 128.132.66.000:116]     __import__(name)
[Wed Nov 18 11:14:16.304225 2015] [:error] [pid 14069] [remote 128.132.66.000:116] ImportError: No module named nested_admin[Wed Nov 18 11:14:29.322753 2015] [:error] [pid 14068] [remote 128.132.66.000:104] mod_wsgi (pid=14068): Target WSGI script '/apps/staging/wisdmepid/django_version/django_version/wsgi.py' cannot be loaded as Python module.[Wed Nov 18 11:14:29.322819 2015] [:error] [pid 14068] [remote 128.132.66.000:104] mod_wsgi (pid=14068): Exception occurred processing WSGI script '/apps/staging/wisdmepid/django_version/django_version/wsgi.py'.[Wed Nov 18 11:14:29.322851 2015] [:error] [pid 14068] [remote 128.132.66.000:104] Traceback (most recent call last):
[Wed Nov 18 11:14:29.322873 2015] [:error] [pid 14068] [remote 128.132.66.000:104]   File "/apps/staging/wisdmepid/django_version/django_version/wsgi.py", line 18, in <module>
[Wed Nov 18 11:14:29.322955 2015] [:error] [pid 14068] [remote 128.132.66.000:104]     application = get_wsgi_application()[Wed Nov 18 11:14:29.322970 2015] [:error] [pid 14068] [remote 128.132.66.000:104]   File "/apps/staging/wisdmepid/django_version/env/lib/python2.7/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
[Wed Nov 18 11:14:29.323024 2015] [:error] [pid 14068] [remote 128.132.66.000:104]     django.setup()
[Wed Nov 18 11:14:29.323034 2015] [:error] [pid 14068] [remote 128.132.66.000:104]   File "/apps/staging/wisdmepid/django_version/env/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
[Wed Nov 18 11:14:29.323096 2015] [:error] [pid 14068] [remote 128.132.66.000:104]     apps.populate(settings.INSTALLED_APPS)[Wed Nov 18 11:14:29.323107 2015] [:error] [pid 14068] [remote 128.132.66.000:104]   File "/apps/staging/wisdmepid/django_version/env/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
[Wed Nov 18 11:14:29.323251 2015] [:error] [pid 14068] [remote 128.132.66.000:104]     app_config = AppConfig.create(entry)
[Wed Nov 18 11:14:29.323266 2015] [:error] [pid 14068] [remote 128.132.66.000:104]   File "/apps/staging/wisdmepid/django_version/env/lib/python2.7/site-packages/django/apps/config.py", line 86, in create
[Wed Nov 18 11:14:29.323374 2015] [:error] [pid 14068] [remote 128.132.66.000:104]     module = import_module(entry)[Wed Nov 18 11:14:29.323393 2015] [:error] [pid 14068] [remote 128.132.66.000:104]   File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
[Wed Nov 18 11:14:29.323448 2015] [:error] [pid 14068] [remote 128.132.66.000:104]     __import__(name)
[Wed Nov 18 11:14:29.323471 2015] [:error] [pid 14068] [remote 128.132.66.000:104] ImportError: No module named nested_admin

I have already installed the module django-nested-admin. I also get the same error when I use django-nested-inline instead of django-nested-admin. Any idea what's wrong?

On the website I get:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost 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.

The code works perfectly in our non-SSL site.
I have already tried solutions mentioned in this and this. Didn't work. Any pointer will be extremely helpful. Thanks.

Here is our apache configuration file. This is not the actual one but the original configuration is in line with this.

<VirtualHost *:80>
    ServerName bogus.example.com:80
    ErrorLog logs/error_log
    TransferLog logs/access_log
    LogLevel warn

    RewriteEngine On
    RewriteRule ^/?sslsite/(.*) https://%{SERVER_NAME}/sslsite/$1 [R,L]


        alias /static/notsslsite /apps/deployment/notsslsite/django_version/static
    <Directory /apps/deployment/notsslsite/django_version/static>
        Require all granted
    </Directory>

    <Directory /apps/deployment/notsslsite/django_version/django_version>
                <Files wsgi.py>
                        Require all granted
                </Files>
        </Directory>

        WSGIDaemonProcess notsslsite processes=2 python-path=/apps/deployment/notsslsite/django_version:/apps/deployment/notsslsite/django_version/env/lib/python2.7/site-packages
        WSGIProcessGroup notsslsite
        WSGIScriptAlias /notsslsite /apps/deployment/notsslsite/django_version/django_version/wsgi.py process-group=notsslsite

</VirtualHost>

<VirtualHost *:443>
    ServerName bogus.example.com:443
    ErrorLog logs/ssl_error_log
    TransferLog logs/ssl_access_log
    LogLevel warn
    SSLEngine on
    SSLProtocol all -SSLv2
    SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
    SSLCertificateFile /etc/httpd/ssl/bogus.example.com.crt
    SSLCertificateKeyFile /etc/httpd/ssl/bogus.example.com.key
    SSLCertificateChainFile /etc/httpd/ssl/bogus_chain.pem


    SetEnvIf User-Agent ".*MSIE.*" \
             nokeepalive ssl-unclean-shutdown \
             downgrade-1.0 force-response-1.0
    CustomLog logs/ssl_request_log \
              "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

        alias /static/sslsite /apps/staging/sslsite/django_version/static
    <Directory /apps/staging/sslsite/django_version/static>
        Require all granted
    </Directory>

    <Directory /apps/staging/sslsite/django_version/django_version>
                <Files wsgi.py>
                        Require all granted
                </Files>
        </Directory>

        WSGIDaemonProcess sslsite processes=2 python-path=/apps/staging/sslsite/django_version:/apps/staging/sslsite/django_version/env/lib/python2.7/site-packages
        WSGIProcessGroup sslsite
        WSGIScriptAlias /sslsite /apps/staging/sslsite/django_version/django_version/wsgi.py process-group=sslsite

</VirtualHost>
Community
  • 1
  • 1
soacq
  • 37
  • 1
  • 7
  • Have you checked read permissions ? Remember that your process might be running under a different user, and possibly with a restricted env. – bruno desthuilliers Nov 23 '15 at 11:54
  • How do you enable SSL? Is your django project behind some HTTP server (nginx, apache) or is it served directly? (uWSGI, gunicorn). How is your ssl and non-ssl server configured? – GwynBleidD Nov 23 '15 at 13:33
  • @brunodesthuilliers it has the same read permissions as the non-SSL one that does work. – soacq Nov 23 '15 at 18:10
  • dumb question, but are you sure it is installed? (pip freeze) – cdvv7788 Nov 23 '15 at 18:15
  • @GwynBleidD we have a ssl certificate. it's behind apache. I don't understand what you mean by how it is configured. However I have added our apace configuration in the question. Thanks. – soacq Nov 23 '15 at 18:22
  • @cdvv7788 yes, it is installed. – soacq Nov 23 '15 at 18:25
  • Try removing that app from your INSTALLED_APPS...does it complain about other app? It may be an issue with apache and your virtualenv. – cdvv7788 Nov 23 '15 at 18:27
  • Thanks but the issue was something else in the code. – soacq Dec 01 '15 at 22:54

1 Answers1

0

This is your WSGIDaemonProcess setting from non-ssl configuration

WSGIDaemonProcess notsslsite processes=2 python-path=/apps/deployment/notsslsite/django_version:/apps/deployment/notsslsite/django_version/env/lib/python2.7/site-packages

And here is from ssl configuration

WSGIDaemonProcess sslsite processes=2 python-path=/apps/staging/sslsite/django_version:/apps/staging/sslsite/django_version/env/lib/python2.7/site-packages

You're using different python-paths for ssl and non-ssl instances and probably nested_admin is not installed in second one. This is only difference that matters for django in your apache settings. Try to set on ssl site same environment as you have on non-ssl and check if it will work. If it will, install proper packages in environment from ssl config. If it won't work, probably your virtual environment is broken, try to recreate it.

GwynBleidD
  • 20,081
  • 5
  • 46
  • 77
  • Thanks for your answer. But the issue was something else in the code that took me like 10 days to figure out . – soacq Dec 01 '15 at 22:53