【发布时间】:2017-07-24 03:26:18
【问题描述】:
我有一个使用 PHP 预配置平台的 Web 服务器环境。我想通过 nginx 将请求传递给代理服务器。这是我在.ebextensions/nginx.config 中的内容:
files:
"/etc/nginx/conf.d/000_my_config.conf":
mode: "000644"
owner: root
group: root
content: |
server {
sub.mysite.com;
listen 80;
location = / {
rewrite ^ http://www.google.com;
}
location / {
proxy_pass http://****.elasticbeanstalk.com;
}
}
文件/etc/nginx/conf.d/000_my_config.conf 在服务器上创建。当我访问sub.mysite.com 时,我没有被定向到谷歌,而是我的应用程序,所以似乎没有加载 nginx 配置。我已经看到其他答案表明要执行 sudo service nginx reload 来重新启动 nginx,但我得到了 nginx: unrecognized service。
【问题讨论】:
-
问题是我使用的 SW 包在其根目录中有一个 .htaccess 文件,所以 Beanstalk 使用 Apache。我不确定 Beanstalk 上的 PHP 是否可以使用 nginx,但我在 .htaccess 文件语句中添加了
RewriteCond和RewriteRule来做我需要的事情。
标签: php amazon-web-services nginx amazon-elastic-beanstalk