Full domain url subfolder redirected my django application with apache with mod_wsgi

310 views
Skip to first unread message

valerio orfano

unread,
Mar 8, 2017, 2:12:57 PM3/8/17
to Django users

I've been facing the following problem. I got django 1.9 integrated with apache 2.4+ via mod_wsgi application. I run manage.py collectstatic and everything is fine when i use the root url. http//10.184.2.231 it is ok and static files are served properly.

Actually i will be redirected to my django app from the link www.mydomain.com/nuovopatentdb

This is my configuration

from urls.py
from django.conf.urls import url
from . import views

urlpatterns = [
    url(r'^$', views.search_ES,name='search_ES'),
    url(r'^nuovopatentdb$', views.search_ES,name='search_ES'), 
    url(r'^download/(?P<id_src>.*)$', views.send_file, name="download"),
    url(r"^documents$", views.documents,name="documents"),
]


#settings.py

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
WSGI_APPLICATION = 'ES_Brevetti.wsgi.application'

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'patentdb.apps.patentdbConfig',
    'mod_wsgi.server',
    'el_pagination',
]


#httpconf.d

Alias '/static' '/home/elastic/workspace/ES_Brevetti/static'

<Directory '/home/elastic/workspace/ES_Brevetti/static'>
<IfVersion < 2.4>
    Order allow,deny
    Allow from all
</IfVersion>
<IfVersion >= 2.4>
    Require all granted
</IfVersion>
</Directory>

This is an example of my template:

<div id="waitLoading" >
    <img src="{%static "images/giphy.gif"%}">
</div>

The image giphy.gif cannot be served and i get the3 follwoing error: GET http://www.mydomain/static/images/giphy.gif 404 (Not Found)

How can i work this around? Many many thanx for ur help

Antonis Christofides

unread,
Mar 8, 2017, 2:34:23 PM3/8/17
to django...@googlegroups.com

You say that you "run manage.py collectstatic and everything is fine when i use the root url. http//10.184.2.231 it is ok and static files are served properly", and then you say that http://www.mydomain/static/images/giphy.gif gives 404 (Not Found).

Is http//10.184.2.231/static/images/giphy.gif working?

If not, why are you saying that "static files are served properly"?

Regards,

Antonis

Antonis Christofides
http://djangodeployment.com
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e2063b5e-9c9e-4802-9439-33e0c69304c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

valerio orfano

unread,
Mar 9, 2017, 2:35:26 PM3/9/17
to Django users
Yes, http//10.184.2.231/static/images/giphy.gif works out properly but www.uibm.gov.it/static/images/giphy.gif does not work.

valerio orfano

unread,
Mar 9, 2017, 5:20:28 PM3/9/17
to Django users
Hi, 

i want to claim that www.mydomain.com is not the FQDN of my server where django app is installed, but it's another server that redirect to my django app.

thanx valerio

ludovic coues

unread,
Mar 10, 2017, 9:13:56 AM3/10/17
to django...@googlegroups.com
This look like an issue with your apache configuration

To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

For more options, visit https://groups.google.com/d/optout.



--

Cordialement, Coues Ludovic
+336 148 743 42

Antonis Christofides

unread,
Mar 10, 2017, 1:06:17 PM3/10/17
to django...@googlegroups.com

Hi,

sorry but this is not clear. You have one server, 10.184.2.231, that has both your django app and your static files? www.uibm.gov.it seems to be another server, 88.49.250.43. www.mydomain.com is a placeholder you are using for www.uibm.gov.it?

Antonis Christofides
http://djangodeployment.com

-- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com. To post to this group, send email to django...@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/6115cee1-cb66-4594-83da-3a696ebc836b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

valerio orfano

unread,
Mar 13, 2017, 11:51:07 AM3/13/17
to Django users
Hi the problem is that i want to mount django app on a subfolder of my root url that is www.mydomain.com. Pratically www.mydomain.com/nuovopatentdb (nuovopatentdb is not really existing , it is used for natting the address to local address) is natted to my django server 10.184.2.231. Now setting : Alias '/nuovopatentdb/static' '/home/elastic/workspace/ES_Brevetti/static' in my httpd.conf mod_wsgi_express_80 i can access the resource www.mydomain.com/nuovopatentdb/images/giphy.gif everything OK! The issue is in my template. The src of my tempalte is : www.mydomain.com/images/giphy.gif  so pratically the subfolder nuovopatentdb is missing. How can i make sure nuovopatentdb appears in the src of my template?

 hope it is clear now?

valerio orfano

unread,
Mar 13, 2017, 2:54:45 PM3/13/17
to Django users
Reply all
Reply to author
Forward
0 new messages