Skip to content

Instantly share code, notes, and snippets.

@Shipu
Last active March 30, 2018 12:59
Show Gist options
  • Save Shipu/71e96af09565f17868b0d107836e1883 to your computer and use it in GitHub Desktop.
Save Shipu/71e96af09565f17868b0d107836e1883 to your computer and use it in GitHub Desktop.
Automatic Virtual host
server {
listen 80;
listen [::]:80;
server_name ~^(www\.)?(?<sname>.+?)$;
root /var/www/html/$sname;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log /var/www/html/$sname-access.log;
error_log /var/www/html/error.log debug;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
server {
listen 80;
listen [::]:80;
server_name ~^(www\.)?(?<sname>.+?)\.lrvl$;
root /var/www/html/laravel/$sname/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# public files
location /storage {
alias /var/www/html/laravel/$sname/storage/app/public;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log /var/www/html/laravel/$sname-access.log;
error_log /var/www/html/laravel/error.log debug;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
server {
listen 80;
listen [::]:80;
server_name ~^(www\.)?(?<sname>.+?)\.master$;
root /var/www/html/default/$sname;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log /var/www/html/default/$sname-access.log;
error_log /var/www/html/default/error.log debug;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
@Shipu
Copy link
Author

Shipu commented Mar 30, 2018

@Shipu
Copy link
Author

Shipu commented Mar 30, 2018

sudo ln -s /etc/nginx/sites-available/laravel-wildcard-nginx.conf /etc/nginx/sites-enabled/laravel-wildcard-nginx.conf && sudo service nginx restart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment