0

I am actually not sure if the title of the topic is actually the source of my issue but there are serious indications for this. I am not an expert in application servers such as apache so any help is most welcome.

I have installed successfully a Django application in a google cloud VM machine (Ubuntu 16.04 with static IP). I am able to access the page but there is no CSS loaded, missing javascript files (e.g. jquery) and several 500 Internal Server Errors.

To give a better idea of the errors, I attach a screenshot enter image description here

The first think I thought is that I have not put the static files in the correct folder for the application server (www/../). But that was not the case.

Then I thought maybe the www folder doesn't have the right permissions. But that wasn't not the case. The user was set correct to: www-data.

My sites-enabled folder of apache2 include my project.conf file.

Then I tried to run this command:

     /usr/sbin/apache2 -S

and I got that back:

VirtualHost configuration:
*:80                   localhost (/etc/apache2/sites-enabled/geonode.conf:3)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex proxy: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl 
Mutex watchdog-callback: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33 not_used
Group: name="www-data" id=33 not_used

As you can see the Main DocumentRoot is in the following folder: "/var/www/html" I was wondering if this could be the reason. Somehow apache is trying to read files from the wrong directory (correct one /var/www/project).

I tried to change the Main DocumentRoot by modifying the parameters in the apache.conf file but whenever I test the changes (/usr/sbin/apache2 -S) I still get the old directory.

I am not even sure that this could be the issue. Any ideas what is going on here?

Note1: I have tried the installation in a local VM and works fine Note2: I have tried in another remote VM and I get the same issue. EDIT

This is the apache error.log file:

[Fri Jun 01 03:42:58.356938 2018] [wsgi:error] [pid 32199:tid 140244594628352] 
Internal Server Error: /favicon.ico
[Fri Jun 01 03:42:58.357214 2018] [wsgi:error] [pid 32199:tid 140244594628352] 
Traceback (most recent call last):
[Fri Jun 01 03:42:58.357347 2018] [wsgi:error] [pid 32199:tid 140244594628352]   
File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 
108, in get_response
[Fri Jun 01 03:42:58.357402 2018] [wsgi:error] [pid 32199:tid 140244594628352]     
response = middleware_method(request)
[Fri Jun 01 03:42:58.357450 2018] [wsgi:error] [pid 32199:tid 140244594628352]   
File "/usr/lib/python2.7/dist-packages/django/middleware/common.py", line 62, 
in process_request
[Fri Jun 01 03:42:58.357496 2018] [wsgi:error] [pid 32199:tid 140244594628352]     
host = request.get_host()
[Fri Jun 01 03:42:58.357556 2018] [wsgi:error] [pid 32199:tid 140244594628352]   
File "/usr/lib/python2.7/dist-packages/django/http/request.py", line 94, 
inget_host
[Fri Jun 01 03:42:58.357603 2018] [wsgi:error] [pid 32199:tid 140244594628352]     
if domain and validate_host(domain, allowed_hosts):
[Fri Jun 01 03:42:58.357651 2018] [wsgi:error] [pid 32199:tid 140244594628352]   
File "/usr/lib/python2.7/dist-packages/django/http/request.py", line 571, in 
validate_host
[Fri Jun 01 03:42:58.357696 2018] [wsgi:error] [pid 32199:tid 140244594628352]     
pattern = pattern.lower()
[Fri Jun 01 03:42:58.357762 2018] [wsgi:error] [pid 32199:tid 140244594628352] 
AttributeError: 'NoneType' object has no attribute 'lower'

EDIT

This is how my configuration file in sites-enabled folder looks like:

WSGIDaemonProcess geonode user=www-data threads=15 processes=2

<VirtualHost *:80>
  Servername localhost
  ServerAdmin webmaster@localhost

  LimitRequestFieldSize 32760
  LimitRequestLine 32760

  ErrorLog /var/log/apache2/error.log
  LogLevel warn
  CustomLog /var/log/apache2/access.log combined

  WSGIProcessGroup geonode
  WSGIPassAuthorization On
  WSGIScriptAlias / /var/www/geonode/wsgi/geonode.wsgi

  <Directory "/var/www/geonode/">
    Order allow,deny
    Options -Indexes
  ]   Allow from all
    Require all granted 
  </Directory>

  Alias /static/ /var/www/geonode/static/
  Alias /uploaded/ /var/www/geonode/uploaded/
  Alias /robots.txt /var/www/geonode/robots.txt

 <Directory "/var/www/geonode/uploaded/documents/">
   Order allow,deny
   Deny from all
 </Directory>

 <Directory "/var/www/geonode/uploaded/layers/">
   Order allow,deny
   Deny from all
 </Directory>

 <Directory "/var/www/geonode/static_root/">
    Order allow,deny
    Options Indexes FollowSymLinks
    Allow from all
    Require all granted
    IndexOptions FancyIndexing
 </Directory>

 <Directory "/var/www/geonode/uploaded/thumbs/">
    Order allow,deny
    Options Indexes FollowSymLinks
    Allow from all
    Require all granted
    IndexOptions FancyIndexing
 </Directory>

 <Directory "/var/www/geonode/uploaded/avatars/">
    Order allow,deny
    Options Indexes FollowSymLinks
    Allow from all
    Require all granted
    IndexOptions FancyIndexing
 </Directory>

 <Directory "/var/www/geonode/uploaded/people_group/">
    Order allow,deny
    Options Indexes FollowSymLinks
    Allow from all
    Require all granted
    IndexOptions FancyIndexing
</Directory>

<Directory "/var/www/geonode/uploaded/group/">
    Order allow,deny
    Options Indexes FollowSymLinks
    Allow from all
    Require all granted
    IndexOptions FancyIndexing
</Directory>

<Proxy *>
  Order allow,deny
  Require all granted 
  Allow from all
</Proxy>

  ProxyPreserveHost On
  ProxyPass /geoserver http://localhost:8080/geoserver
  ProxyPassReverse /geoserver http://localhost:8080/geoserver
</VirtualHost>
7
  • 2
    500 errors should mean either a useful error message if you visit one of those URLs, or in your logs if error reporting is turned off.
    – ceejayoz
    May 31, 2018 at 17:12
  • @ceejayoz I added the logs from the apache error.log file. I don't see a good hint for the source of the problem there. Do you?
    – user1919
    Jun 1, 2018 at 8:48
  • Do you have a favicon.ico file in the app? It's being routed through the Django app instead of being served directly. Same appears to be true for stuff like 35.195.135.248/lib/css/assets.min.css.
    – ceejayoz
    Jun 1, 2018 at 12:20
  • Yes! Although the favicon.ico and the other files exist both in the Django app and the www folder, for some reason they are loaded from the wrong place. Although I have defined the paths in my apache.conf file.
    – user1919
    Jun 1, 2018 at 13:49
  • 1
    Alias /static/ /var/www/geonode/static/ means all your static assets need /static/ before them. i.e. 35.195.135.248/static/lib/css/assets.min.css works fine. Adjust your templates accordingly.
    – ceejayoz
    Jun 1, 2018 at 14:28

1 Answer 1

0

Try to set the DocumentRoot like this:

<VirtualHost *:80>
    DocumentRoot /var/www/project
</VirtualHost>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .