wildcard setup for subdirectories

rajibmp's picture

I am not sure if we'd pursue with multisite installation, but at the moment we have one site which supports multiple language like:
example.com/en
example.com/es

There seems to be a translation bug/error while using this setup, so, we are thinking about using it as subdomain (might be multisite) like:
en.example.com
es.example.com

But again, we'd also have some other feature not directly related with main site (only the user information) like:
blog.example.com
community.example.com

This would create lots of subdomains and i was surfing how to accomplish this in D7 site with Nginx, there were few suggestions like using Magic regex http://publications.jbfavre.org/web/nginx-vhosts-automatiques-avec-SSL-e...
OR making a separate server block http://serverfault.com/questions/412530/map-requests-based-on-subdomain
OR using wildcard server name as
server_name _;

I don't know if using _ in server name would be a good idea, but other methods I have linked above again causes redirection errors as said here http://serverfault.com/questions/461098/nginx-incorrectly-forwarding-dyn......

So, what you guys think about using such setup having _ as server name ?

Comments

There shouldn't be any problems

perusio's picture

the fact that you're using _ as a server_name means that the $host embedded variable will have the value _ whenever a Host header is not sent in the request.

Be careful if you have a default server block to handle illegal Host headers usually the _ is the proposed server name. Use # or @ in that case.

Maby better use server_name

chilic's picture

Maby better use server_name *.example.com;

That is http://serverfault.com/questions/461098/nginx-incorrectly-forwarding-dyn... bad idea.

using * in server name

rajibmp's picture

doesn't look good idea, specially if you have different root folder. As example.com may point to www/index.php *.example.com will point to same root folder/file... Thats why in one of the above link I posted had several server blocks to cover different root folders.

I have a config to not allow other hosts, but in this case I might have to disable that... I will try your suggestion