python - django behind subdomain on localhost with nginx -


i have django project want display diferent content according subdomain it's being accessed, example, when user enters url: http://e1.example.com/ displays «welcome e1 site», when user enters to: http://e2.example.com displays «welcome e2 site» , on.

so have nginx configuration:

upstream example_project{     server localhost:8200; }  server {     listen  80;     server_name ~^(?<event>.+)\.example\.com;      location / {         proxy_pass http://example_project/$event$request_uri;     } } 

and have /etc/hosts file following:

127.0.0.1   example.com 127.0.0.1   e1.example.com 127.0.0.1   e2.example.com 

when go http://localhost:8200/e1/ works, when go http://e1.example.com/ shows 400 error

on django console output have:

[18/aug/2014 14:33:31] "get /e1/ http/1.1" 200 39 <-- when going localhost:8200/e1/ [18/aug/2014 14:33:33] "get /e1/ http/1.0" 400 26 <-- when going e1.example.com 

so can see e1.example.com calling project correct url, why browser show me 400 error?

ok, realized have put more proxy parameters nginx, have nginx configuration with:

location / {     proxy_pass_header server;     proxy_set_header host $http_host;     proxy_redirect off;     proxy_set_header x-real-ip $remote_addr;     proxy_set_header x-scheme $scheme;     proxy_pass http://example_project/$event$request_uri; } 

end everythnig works desired. maybe going similar. :)


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -