Skip to content

Instantly share code, notes, and snippets.

@sheikhwaqas
Last active September 30, 2021 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sheikhwaqas/6dae3e0f4c2c9c75b5ba95faa40fb47e to your computer and use it in GitHub Desktop.
Save sheikhwaqas/6dae3e0f4c2c9c75b5ba95faa40fb47e to your computer and use it in GitHub Desktop.
Nginx Configuration for Laravel 8.x Deployment
server {
listen 80;
listen [::]:80;
server_name <domain_name>;
root <document_root>;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
index index.php;
charset utf-8;
location ~* \.(css|js|ico|gif|jpeg|jpg|webp|png|svg|eot|otf|woff|woff2|ttf|ogg|mp4)$ {
expires max;
fastcgi_hide_header Set-Cookie;
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
}
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include snippets/fastcgi-php.conf;
}
location ~ /\.(?!well-known).* {
deny all;
}
location ~ /\.ht {
deny all;
}
location ~ /\.git {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment