Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 如果我通过AWS弹性IP发出请求,Nginx不会处理请求_Amazon Web Services_Nginx_Amazon Ec2_Elastic Ip - Fatal编程技术网

Amazon web services 如果我通过AWS弹性IP发出请求,Nginx不会处理请求

Amazon web services 如果我通过AWS弹性IP发出请求,Nginx不会处理请求,amazon-web-services,nginx,amazon-ec2,elastic-ip,Amazon Web Services,Nginx,Amazon Ec2,Elastic Ip,我有一个ec2实例,它有两个接口,et0和et1。我给那个接口分配了2个弹性IP。et0工作正常,向分配给该IP的IP发出的请求由该默认\u服务器的服务器处理;nginx配置。在/etc/nginx/sites available/default中,我为第二个接口et1进行了配置: server { listen 172.31.13.104:80; #listen [::]:80 default_server; server_name example2.com;

我有一个ec2实例,它有两个接口,et0和et1。我给那个接口分配了2个弹性IP。et0工作正常,向分配给该IP的IP发出的请求由该默认\u服务器的服务器处理;nginx配置。在/etc/nginx/sites available/default中,我为第二个接口et1进行了配置:

server {
    listen 172.31.13.104:80;
    #listen [::]:80 default_server;
    server_name example2.com;
    return 301 http://google.com;
}
如果我从第二个aws实例向172.31.13.104发出请求,我将收到到google的正确重定向。但当我使用公共弹性搜索请求时,它一直处于挂起状态。当我在et1上的服务器上运行tcptruck,并在我的计算机上向elastic IP发出请求时,在服务器上我看到请求和请求状态仍然显示SYN_SENT。我应该怎么做才能使nginx正常工作

编辑:
172.31.13.104 et1的私有IP问题是否由我自己解决。我的IP路由规则不正确,下面是如何配置IP表的教程

我遇到了同样的问题,这就是我解决问题的方法。您需要两个拥有自己IP的ENI,您需要将它们配置到各自的域,然后为两个连接中的每一个创建一个配置文件

下面是我在rhel服务器上必须做的事情,以使其正常工作

$ cd /etc/sysconfig/network-scripts
 $ sudo cp ifcfg-eth0 ifcfg-eth1
$ sudo vi ifcfg-eth1
-将DEVICE=eth0更改为DEVICE=eth1并保存了文件

  $ sudo vi /etc/rc.local
 -- added the following lines and saved the file ip route add default via 172.31.48.1 dev eth0 table 20 ip rule add from 172.ip1 table 20 ip
 route add default via 172.31.48.1 dev eth1 table 21 ip rule add from
 172.ip2 table 21
-请将172.31.48.1替换为您接口的网关,您将从“route-n”输出中获得此信息 -将172.ip1替换为eth0的私有IP地址,将172.ip2替换为eth1的私有IP地址。您将从“ifconfig”输出中获得这些地址

$ sudo chmod +x /etc/rc.local
之后,请重新启动或停止/启动实例,一旦实例启动,您将能够使用任一EIP登录。登录后,您可以通过运行以下命令验证两个接口是否可以通过internet进行通信:

$ ping -I eth0 google.com (this will ping google.com from interface eth0)
$ ping -I eth1 google.com (this will ping google.com from interface eth1)
您应该从两个ping获得ping响应

完成此操作后,需要在apache中配置基于IP的虚拟主机[5]。这将允许您从不同域/子域的不同目录中获取不同的内容

然后,您需要创建一个资源记录集[6],以便将名为“poc.domain.com”的子域的流量路由到您案例中的IP地址eth1的EIP

最后,您需要根据您的要求关联/更改每个ENIs eth0和eth1的安全组[7]

端口80是否在分配给实例的安全组和实例上运行的任何防火墙软件(如iptables)中都打开?