【发布时间】:2016-07-29 03:44:57
【问题描述】:
我正在尝试使用 nginx 从子域反向代理到 Laravel(版本 5.2)提供的 url。在我的顶级域 (domain.com) 中,它在 url domain.com/sub 上提供。我希望它可以通过域sub.domain.com 访问。它应该代理sub.domain.com 与domain.com/sub 提供相同的服务。这是我用于反向代理的 nginx 配置文件
server {
listen 80;
server_name sub.domain.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://domain.com/sub;
}
}
这是我用于 laravel 应用程序的 nginx 配置文件
server {
listen 80;
listen [::]:80;
# Useful logs for debug.
access_log /var/www/domain/access.log;
error_log /var/www/domain/error.log;
rewrite_log on;
root /var/www/domain/public;
index index.php index.html index.htm;
server_name domain.com local.domain;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
}
但它返回了500 internal server error。有什么建议可以解决它或如何实现它?谢谢:)
【问题讨论】:
-
错误 500 表示错误在应用程序中。你能分享错误堆栈跟踪吗?在日志文件中。
-
嗯,我不认为它在应用程序中。因为它像往常一样工作,如果我从
domain.com/sub访问它但是让我检查它的日志 -
Nginx 错误日志,然后。
-
gist.github.com/ans-4175/52f9fea034a92e2e3e494998bffb9b6e 有错误日志我有 2 个 nginx.conf,一个用于 laravel app conf,另一个是代理 conf。我认为这是从代理到应用程序的循环。嗯
-
尝试在proxy_pass url中添加斜杠;
http://domain.com/sub/
标签: php laravel nginx proxy laravel-5.2