Report this

What is the reason for this report?

configure multiple subdomains with nginx...

Posted on July 19, 2014

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;

        server_name xyz.com  .xyz.com;

        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;
        }
}

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.