Hacker News new | past | comments | ask | show | jobs | submit login
Using subdomains (e.g. http://XYZ.someserver.com) with django (2scomplement.com)
21 points by nocivus on Oct 21, 2008 | hide | past | favorite | 9 comments



WARNING: don't use subdomains if you want users in China to be able to get to your site. By default, most/all subdomains managed like this do not get put in China's DNS properly. Get used to life with the great firewall, it is what it is ;)


I still manage to get spam from China on a site with subdomains. It would actually be a feature if I could easily block all of China.


You can always do a country lookup from APNIC that will give you all of the IP's assigned to China (or any other country that regional registrar manages).

http://www.apnic.net/apnic-bin/ipv4-by-country.pl?country=CN

I wrote a script a while back that parses that list and creates an access-list for country blocking. Maybe I'll put it online one day.

At least that's how us network folk do it.


its not an absolute. but if you count on subdomains working for your users, you will be disappointed.

And if you think only spamming happens from China, you haven't compared the current account balances of the U.S. and China lately ;).


Really? Do you know why that happens? Is it intentional, from their government?


There is no published policy for how and why things get blocked. The behavior of the firewall changes over time.

The subdomains problem seems to do more with DNS replication and pessimistic acceptance of DNS records more so than a person actually censoring content.


Why should django deal with subdomains. Just use mod_rewrite or whatever your server offers to map your internal urls. myname.mydomain.com -> mydomain.com/myname/


It's much cleaner to have it taken care of in Django than through mod_rewrite. For one all of your URL routing will still work. In your setup using {% url %} or reverse() wouldn't work.


Yeah I agree here. Putting that inside of your application and outside your web server config makes more sense to me. Especially using the reverse url matching, which is so amazingly wonderful (especially when you give your url's unique names like user-account-settings and can simply do {% url user-account-settings %} and be done with it). Hat tip to obeattie.com for all my django template ramblings above ;)




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: