tim*_*xyz 5 amazon-web-services amazon-route53 amazon-elastic-beanstalk
我想拥有www.example.com,staging.example.com并且demo.example.com,每个映射到Elastic Beanstalk上相同应用程序的单独环境.
这可能吗?
在我的托管区域中example.com.,我设置了cname记录www.example.com,staging.example.com并且demo.example.com每个记录都有一个指向其各自EB网址的值.
我设置的第一个www.example.com工作和请求到达环境.但是当我试图与其他人联系时ping staging.example.com,结果是ping: cannot resolve staging.example.com: Unknown host.
www.example.com工作正常这有可能开始工作吗?
注意:我已经用我的实际域名替换了example.com.
我可能会越来越近但它还没有工作,它正在回归You don't have permission to access /user.
根据此链接,https://serverfault.com/questions/407961/setting-up-subdomains-within-amazon-aws-elastic-beanstalk.
我补充说:
files:
"/etc/httpd/conf.d/vhost.conf":
mode: "000644"
owner: root
group: root
encoding: plain
content: |
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "/var/app/current/"
<Directory "/var/app/current/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName staging.example.com
DocumentRoot "/var/app/current/your-new-webroot"
<Directory "/var/app/current/your-new-webroot">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
现在,当我跑步时ping staging.example.com,响应是:
PING示例... elasticbeanstalk.com(35.182.128.147):56个数据字节
哪个好.但是当我试图提出我的实际要求时:
curl -X POST -H "Content-Type: application/json"
-H "Authorization: Bearer ..." -d '{}' https://staging.example.com/user
Run Code Online (Sandbox Code Playgroud)
回应是:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /user
on this server.<br />
</p>
</body></html>
Run Code Online (Sandbox Code Playgroud)
我重新排序了我的VirtualHosts并添加了ServerName,所以它现在看起来像这样:
files:
"/etc/httpd/conf.d/vhost.conf":
mode: "000644"
owner: root
group: root
encoding: plain
content: |
NameVirtualHost *:80
<VirtualHost *:80>
ServerName staging.example.com
DocumentRoot "/var/app/current/your-new-webroot"
<Directory "/var/app/current/your-new-webroot">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName www.example.com
DocumentRoot "/var/app/current/"
<Directory "/var/app/current/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
但我仍然得到了我的POST请求相同的回复:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /user
on this server.<br />
</p>
</body></html>
Run Code Online (Sandbox Code Playgroud)
另外,根据我的/var/log/httpd/error_log日志:
AH01630: client denied by server configuration: /var/app
Run Code Online (Sandbox Code Playgroud)
几点.
更新了Directory和DocumentRoot指向我的应用程序文件实际存储在我的烧瓶应用程序的服务器上的位置"/opt/python/current/app",之前我复制并粘贴了"/var/app/current/".
检查我的apache版本httpd -v.结果是,Server version: Apache/2.4.27 (Amazon) \n Server built: Sep 24 2017 23:19:50
更新后的文件:
files:
"/etc/httpd/conf.d/vhost.conf":
mode: "000644"
owner: root
group: root
encoding: plain
content: |
NameVirtualHost *:80
<VirtualHost *:80>
ServerName staging.example.com
DocumentRoot "/opt/python/current/app"
<Directory "/opt/python/current/app">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName www.example.com
DocumentRoot "/opt/python/current/app"
<Directory "/opt/python/current/app">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
仍然得到相同的结果.
之所以有效ping staging.example.com,是因为您的 CNAME 解析正确。然而,该VirtualHost指令以线性方式应用。由于您的第一VHost部分不包含ServerName,因此它默认应用于所有请求。
更改这两个部分的顺序VHost,或者ServerName向所有部分添加 a,一切就应该开始工作(可能需要重新启动 EB 应用程序)。
如果 403 错误有其他原因,您还可以检查计算机本身的日志文件。
| 归档时间: |
|
| 查看次数: |
173 次 |
| 最近记录: |