laravel lumen project as subdirectory with nginx


  • | 661 points

    Hi everyone,
    I'm trying configure a project using lumen laravel with nginx on laragon.
    But I'm having a problem when make it run as subdirectory.
    Example domain run at http://project.local/api/ and project located at D:\projects\api
    Does someone has experiment with this case, please give me some suggestion.
    There is my current config

    server {
    	listen 8172;
    	server_name project.local;
    	charset utf-8;
    
    	root "D:/project/home";
    	index index.html index.htm index.php;
    
    	location / {
    		try_files $uri $uri/ /index.php?$query_string;
    	}
    
    	location ^~ /api {
    		alias "D:/project/api";
    		try_files $uri $uri/ @siteApi;
    		location ~ \.php$ {
    			include snippets/fastcgi-php.conf;
    			include fastcgi_params;
    			fastcgi_pass php_upstream;
    			fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    		}
    	}
    	location @siteApi {
    		rewrite ^/api/(.*)$ /api/index.php/$1 last;
    	}
    	location ~ \.php$ {
    		include snippets/fastcgi-php.conf;
    		include fastcgi_params;
    		fastcgi_pass php_upstream;
    		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    	}
    	location = /favicon.ico { access_log off; log_not_found off; }
    	location = /robots.txt  { access_log off; log_not_found off; }
    	location ~ /\.ht {
    		deny all;
    	}
    
    	gzip on;
    	gzip_vary on;
    	gzip_disable "msie6";
    	gzip_comp_level 9;
    	gzip_min_length 1100;
    	gzip_buffers 16 8k;
    	gzip_proxied any;
    	gzip_types
    		text/plain
    		text/css
    		text/js
    		text/xml
    		text/javascript
    		application/javascript
    		application/x-javascript
    		application/json
    		application/xml
    		application/xml+rss;
    }
    

    Thanks


Log in to reply
 

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