5 ms·
Using subdomains (e.g. http://XYZ.someserver.com) with django
- jhancock 18y agoWARNING: 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 ;)
- nocivus 18y agoReally? Do you know why that happens? Is it intentional, from their government?
- jhancock 18y agoThere 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.
- jonknee 18y agoI 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.
- tannerhiland 18y agoYou 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 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.
- jhancock 18y agoits 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 ;).
- niels 18y agoWhy 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/
- jonknee 18y agoIt'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.
- whalesalad 18y agoYeah 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 ;)