Project's virtual host does not have any effect.


  • | 494 points

    I'm trying to have a subdomain like api.mysite.test that uses the /mysite/api directory as it's root. But when I'm visiting api.mysite.test, it returns a DNS_PROBE_FINISHED_NXDOMAIN error saying the site isn't available.

    This is my mysite.test.conf file within sites-enabled, I have removed the auto prefix and restarted Nginx after I changed the file. Anyone knows what I'm missing?

    server {
        listen 80;
        server_name mysite.test;
        root "C:/laragon/www/mysite/";
        
        index index.html index.htm index.php;
     
        location / {
            try_files $uri $uri/ /index.php$is_args$args;
    		autoindex on;
        }
        
        location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass php_upstream;		
            #fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        }
    	
    	
        charset utf-8;
    	
        location = /favicon.ico { access_log off; log_not_found off; }
        location = /robots.txt  { access_log off; log_not_found off; }
        location ~ /\.ht {
            deny all;
        }
    }
    
    server {
        listen 80;
        server_name api.mysite.test;
        root "C:/laragon/www/mysite/api/";
        
        index index.html index.htm index.php;
     
        location / {
            try_files $uri $uri/ /index.php$is_args$args;
    		autoindex on;
        }
        
        location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass php_upstream;		
            #fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        }
    	
    	
        charset utf-8;
    	
        location = /favicon.ico { access_log off; log_not_found off; }
        location = /robots.txt  { access_log off; log_not_found off; }
        location ~ /\.ht {
            deny all;
        }
    }
    
    # This file is auto-generated.
    # If you want Laragon to respect your changes, just remove the [auto.] prefix
    # If you want to use SSL, enable it at: Menu > Nginx > SSL > Enabled
    
    
    

  • administrators
    | 122979 points

    @amirakbulut : You should click the h symbol then add api.mysite.test to hosts file also


  • | 494 points

    Thanks @leokhoa, is there also a way for it to be dynamic? Something like *.mysite.test isn't working. My project is multi tenant and I'm not able to add each tenant to my host file.


  • administrators
    | 122979 points

    @amirakbulut : Windows hosts file doesn't support wildcard domains. You need to use other solution like this one:
    https://mayakron.altervista.org/support/acrylic/Home.htm


Log in to reply
 

Looks like your connection to Laragon was lost, please wait while we try to reconnect.