Django-Hosts Routing issue in Production
Closed this issue · 1 comments
bobozar commented
Django-hosts is working perfectly fine on my development server. But it's not working fine on the production server. when I visit m.example.com it will redirect me to example.com.
I have one project with different apps. I only want the subdomain to make use of mravmomentapp.
E.g
project name: mrav
apps under: mrav/moneapp
mrav/mtwoapp
mrav/mravmomentapp
My stack is nginx, wsgi, gunicorn.
I placed the hosts.py in mrav/hosts.py
In my hosts.py
if socket.gethostname()=="AM-PC":
host_patterns = patterns('',
host(r'examplelocal.com:8000', mrav_base_settings.ROOT_URLCONF, name='www'),
host(r'm.examplelocal.com:8000', 'mravmomentapp.urls', name='m'),
)
###use this settings in production
else:
host_patterns = patterns('',
host(r'example.com', mrav_base_settings.ROOT_URLCONF, name='www'),
host(r'm.example.com', 'mravmomentapp.urls', name='m'),
)
In my mravmomentapp.urls I have
urlpatterns =[
url(r'^$', mo_views.home_page, name='home_page'), #homepage for subdomain m.example.com
]
in my nginx.conf
server {
listen 80;
listen [::]:80;
server_name example.com www.example.com *.example.com m.example.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name example.com www.example.com;
index index.html index.htm index.php;
include snippets/ssl-example.com.conf;
include snippets/ssl-params.conf;
location / {
include proxy_params;
proxy_pass http://mrav_app_server;
}
#othersettings
}
I also created an A host file in my DNS and added my IP ADDRESS to it.
What am I missing?
bobozar commented
Fixed. I created another server in nginx.