configure multiple subdomains with nginx...

Hi everyone,

I am having an issue with nginx configuration when it comes to multiple (over 1000) subdomains. Please help, I got stuck …

I am trying to redirect all of the sites below to the same web root:

I have:

  1. Ubuntu 14.04, Laravel 4, nginx. Everything is latest version
  2. Added DNS CNAME, where NAME=* and HOSTNAME=@
  3. And finally, my nginx config looks like this:
server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;

        root /var/www/laravel/public;
        index index.php index.html index.htm;


        try_files $uri $uri/ @rewrite;

        location @rewrite {
                rewrite ^/(.*)$ /index.php?_url=/$1;

        location ~ \.php$ {
                try_files $uri /index.php =404;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.




server_name  *;

and restart nginx.