php - 如何使用 Laravel Forge 和 AWS 在专用域上创建自定义子域?
问题描述
我无法将 Laravel 5.2 应用程序从 cPanel / phpMyAdmin 迁移到 Laravel 5.8、Forge 和 AWS。
使用旧系统,我们能够让我们的用户在他们自己的品牌域以及我们平台上的子域上创建自定义子域。
例如*.theircompany.com
// 这不起作用
或*.ourcompany.com
// 这有效
其中 * 是在我们平台上创建的子域。
这是通过让用户创建指向我们的根域的 CNAME 记录,并通过具有 /public_html 文档根的 cpanel 将用户域停放在我们的域列表中来实现的
我们希望为我们的用户保持尽可能简单,只使用 cname,因为现有用户会被迁移打乱。
在 Laravel 5.2 中,我相信“索引”文件是 server.php,位于 public_html 中,看起来像这样
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <taylorotwell@gmail.com>
*/
$uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);
// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
return false;
}
require_once __DIR__.'/public/index.php';
当我访问用户域上的子域时,我收到 404 nginx 错误。
404 Not Found
nginx/1.15.8
所以我猜这个错误是因为 nginx 配置,但我不知道如何调试。
但是,我可以看到请求正在登录/var/log/nginx/access.log
:
[17/Jul/2019:17:42:40] "GET /tesrt HTTP/1.1" 404 185 "-" "Mozilla/5.0
如何使用 Laravel Forge 和 AWS 实现这一点?Route53 有必要吗?
解决方案
添加第二个服务器块使用 http(非 https)端口 80 修复了此问题
server {
listen 80;
listen [::]:80;
server_name ~. "";
# ... same config without SSL
}
推荐阅读
- python - 根据不同数据框中的匹配值将汇总列添加到熊猫数据框中
- android-studio - android studio中的底部导航栏
- node.js - mongoose 未连接到 mongodb 服务器
- c++ - 构建后立即在向量上调用 clear?
- python - 通过使用 read_csv() 从多个文件中读取数据来创建多级 DataFrame [已解决]
- javascript - 如何仅在交易完成后重定向?
- css-grid - 3x3 网格,中间列较宽,顶部和底部单元格较短,但不会改变两侧单元格的高度
- javascript - 使用 javascript 进行媒体查询
- c# - 使用 Clean Architecture 进行自定义实体验证
- manim - 如何确定多边形的边缘中心