Yes, you can use Laravel Forge to set up wildcard subdomains. Here are the steps:
Step 1: Create a New Site in Laravel Forge
1. Create a New Site:
- Log in to your Laravel Forge account.
- Click on the "Create Site" button.
- Enter the primary domain for your application (e.g., `myapp.com`).
- Check the box for "Allow Wildcard Sub-Domains" at the bottom of the form.
Step 2: Configure Nginx
1. Edit Nginx Configuration:
- In the "Nginx" tab, click on the "Edit" button.
- Update the Nginx configuration to include the wildcard subdomains:
nginx
server {
listen 80;
server_name ~^(.*)\.myapp\.com$;
root /var/www/laravel_project/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?_share=++;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
}
}
Step 3: Configure DNS
1. Create DNS Records:
- In your DNS provider (e.g., AWS Route 53), create a wildcard A record for the domain:
bash
* IN A 192.0.2.1
Step 4: Test the Setup
1. Test the Setup:
- Visit each subdomain (e.g., `staging.mysite.com`, `beta.mysite.com`) to ensure they are working as expected.
By following these steps, you can set up wildcard subdomains using Laravel Forge.
Citations:[1] https://laracasts.com/discuss/channels/forge/wildcard-subdomains-point-to-new-laravel-apps-with-forge-setup
[2] https://mattstauffer.com/blog/laravel-forge-wildcard-subdomains/
[3] https://dev.to/arielmejiadev/set-dynamic-subdomains-in-laravel-forge-5fi8
[4] https://laracasts.com/discuss/channels/forge/adding-a-sub-domain-with-laravel-forge
[5] https://stackoverflow.com/questions/49313076/laravel-forge-add-wildcard-subdomain-to-existing