linux - Apache2 到 Nginx - Laravel 7
问题描述
浏览网站时,它只是尝试下载登录页面,请协助
我的 www/website/public 文件夹中有一个 .htaccess 文件(想将其添加到我的 nginx 配置中)
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# CORS Fix
Header set Access-Control-Allow-Origin "*"
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
我有这个 nginx 配置(从 http 重定向到 https 和主站点)
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name clipdrop.io www.clipdrop.io;
root "/var/www/website/public";
error_log /var/www/logs/www.clipdrop.io.error.log;
access_log /var/www/logs/www.clipdrop.io.requests.log;
ssl_certificate /etc/apache2/ssl/clipdrop/clipdrop.crt;
ssl_certificate_key /etc/apache2/ssl/clipdrop/clipdrop.key;
index index.php;
# serve static files directly
location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
access_log off;
expires max;
log_not_found off;
}
# removes trailing slashes (prevents SEO duplicate content issues)
if (!-d $request_filename)
{
rewrite ^/(.+)/$ /$1 permanent;
}
# enforce NO www
if ($host ~* ^www\.(.*))
{
set $host_without_www $1;
rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent;
}
# unless the request is for a valid file (image, js, css, etc.), send to bootstrap
if (!-e $request_filename)
{
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~* \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass app:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
主网站根目录位于 /var/www/website/ 公用文件夹位于该目录中
解决方案
推荐阅读
- reactjs - 在 IE10 中反应未定义的地图
- react-native - React-Navigation 5 TypeError:无法读取未定义的属性'_context' 此错误位于forwardRef(BaseNavigationContainer)
- java - 如何实现在 X 分钟内未收到任何事件后发出的 Flink 事件时间触发器
- c# - Discord.NET 从一个控制台应用程序项目运行多个机器人
- reactjs - 命令 create-react-app 不运行,它会产生错误
- javascript - 基于另一个 CSS 样式元素的 Javascript 内联旋转变换样式
- javascript - 将 PHP 变量传递给 javascript,包括引号和 javascript
- java - 如何动态更改状态栏中的文本
- python - python应用程序在我使用vpn或@work的地方不起作用
- python-3.x - 如何在用户定义的函数中使用 print() 实现多行打印?