Dynamic Sub Domain Routing with NGINX And laravel
I have setup sub domain routing with nginx and laravel for my development site, but for some reason when i access the site with www.lunch.test it works but when i access the site with companyA.lunch.test it doesn’t work.
Below is my nginx lunch.conf file. I will be on stand by for solution.
listen 80; server_name www.lunch.test lunch.test *.lunch.test; root /var/www/html/lunch/public; index index.html index.htm index.php; charset utf-8; location / { try_files $uri $uri/ /index.php$is_args$args; } location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } access_log on; error_log /var/www/html/lunch/storage/logs/error.log error; access_log /var/www/html/lunch/storage/logs/access.log main; sendfile off; client_max_body_size 100m; location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_intercept_errors off; fastcgi_buffer_size 16k; fastcgi_buffers 4 16k; fastcgi_read_timeout 300; } location ~ /\.ht { deny all; } }
Thanks to all viewers, i was able to resolve the issue by mapping the domain name to the ip address in /etc/hosts
file like so, xxx.xxx.xxx.xxx companyA.lunch.test