Question
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:
- 1. xyz.com
- 2. sub1.xyz.com
- 3. sub2.xyz.com
- 4. sub3.xyz.com
- …
I have:
- Ubuntu 14.04, Laravel 4, nginx. Everything is latest version
- Added DNS CNAME, where NAME=* and HOSTNAME=@
- 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;
}
}
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.
×