Skip to content

Instantly share code, notes, and snippets.

@iSWORD
Created June 20, 2018 08:46
Show Gist options
  • Save iSWORD/dcd9379dc8eae21772477b91146554d2 to your computer and use it in GitHub Desktop.
Save iSWORD/dcd9379dc8eae21772477b91146554d2 to your computer and use it in GitHub Desktop.
.laravel + .localhost TLDs with dynamic nginx configuration
echo 'address=/localhost/127.0.0.1' | sudo tee /etc/NetworkManager/dnsmasq.d/development-tlds > /dev/null
echo 'address=/laravel/127.0.0.1' | sudo tee -a /etc/NetworkManager/dnsmasq.d/development-tlds > /dev/null
sudo service NetworkManager reload
# Nginx config file for .laravel tlds
server {
listen 80;
listen [::]:80;
server_name ~^(?<subdomain>.+)\.laravel$;
root /var/www/$subdomain/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
}
# Nginx config file for .localhost tlds
server {
listen 80;
listen [::]:80;
server_name ~^(?<subdomain>.+)\.localhost$;
root /var/www/$subdomain;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment