فهرست منبع

:bug: fix laravel@nginx

Jeremy Zheng 3 سال پیش
والد
کامیت
265a68d3b7
2فایلهای تغییر یافته به همراه27 افزوده شده و 4 حذف شده
  1. 5 0
      scripts/spring/laraven.sh
  2. 22 4
      scripts/spring/user.sh

+ 5 - 0
scripts/spring/laraven.sh

@@ -0,0 +1,5 @@
+#!/bin/sh
+
+chmod 666 storage/logs/*.log
+
+chmod 777 storage/logs storage/framework/sessions

+ 22 - 4
scripts/spring/user.sh

@@ -40,22 +40,40 @@ if [ ! -f /workspace/www/$1/nginx.conf ]
 then
     # https://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names
     cat > /workspace/www/$1/nginx.conf <<EOF
+# https://laravel.com/docs/9.x/deployment#nginx
+
 server {
   listen 80;
-  root /workspace/www/$1/htdocs;
-  index index.html index.php;
   server_name ${1//_/-}.spring.wikipali.org;
 
   access_log /workspace/www/$1/logs/access.org;
   error_log /workspace/www/$1/logs/error.log;
 
+  add_header X-Frame-Options "SAMEORIGIN";
+  add_header X-Content-Type-Options "nosniff";
+
+  root /workspace/www/$1/htdocs/public;
+  index index.html index.php;
+
+  charset utf-8;
+  gzip on;
+  client_max_body_size 16M;
+
   location / {
-    try_files \$uri \$uri/ =404;
+    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$ {
-    include snippets/fastcgi-php.conf;
     fastcgi_pass unix:/run/php/php-fpm.sock;
+    fastcgi_param SCRIPT_FILENAME \$realpath_root\$fastcgi_script_name;
+    include fastcgi_params;
+  }
+  location ~ /\.(?!well-known).* {
+    deny all;
   }
 }
 EOF