Skip to content

Instantly share code, notes, and snippets.

@memandip
Created December 10, 2021 09:19
Show Gist options
  • Save memandip/72afe8243c8ebdaf90d76591a2105b86 to your computer and use it in GitHub Desktop.
Save memandip/72afe8243c8ebdaf90d76591a2105b86 to your computer and use it in GitHub Desktop.
Nginx configuration with laravel and static site. Routes with prefix `api` will be handled by laravel
server {
server_name mydomain.com;
charset utf-8;
root /var/www/html/{Laravel_Project_DIR}/current/public;
index index.html index.php;
location /api {
try_files $uri $uri/ /index.php?$query_string;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
}
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
}
location / {
root /var/www/html/{STATIC_SITE_DIR};
try_files $uri $uri/ /index.html?$query_string;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment