Last active
September 30, 2021 09:54
-
-
Save sheikhwaqas/6dae3e0f4c2c9c75b5ba95faa40fb47e to your computer and use it in GitHub Desktop.
Nginx Configuration for Laravel 8.x Deployment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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