2013-03-26 45 views
1

我运行亚马逊的Linux AMI和nginx的,当我尝试启动我的nginx服务器:nginx的错误绑定无法分配请求地址

$ sudo /etc/init.d/nginx restart 

我收到以下错误:

nginx: [emerg]: bind() to IP failed (99: Cannot assign requested address) 

其中“IP “是我的IP地址的占位符。有人知道为什么会发生这种错误?这在EC2上运行。

我的nginx.conf文件看起来像这样:

user    app; 
worker_processes 4; 

#error_log /var/log/nginx/error.log; 
#error_log /var/log/nginx/error.log notice; 
error_log /var/log/nginx/error.log info; 

pid  /var/run/nginx.pid; 

events { 
    worker_connections 1024; 
} 

http { 
    include  /etc/nginx/mime.types; 
    default_type application/octet-stream; 

    access_log /var/log/nginx/access.log; 

    sendfile  on; 
    tcp_nopush  on; 
    tcp_nodelay on; 

    #keepalive_timeout 0; 
    keepalive_timeout 65; 

    gzip on; 
    gzip_http_version 1.0; 
    gzip_comp_level 2; 
    gzip_proxied any; 
    gzip_types text/plain text/html text/css application/x-javascript application/xml application/xml+rss text/javascript; 

    server_names_hash_bucket_size 64; 

    include /etc/nginx/conf.d/*.conf; 
    include /etc/nginx/sites-enabled/*; 
    server { 
     listen   IP:443; 
     server_name  name; 
     include /etc/nginx/ssl.conf; 
    } 
} 

kirpit说:与亚马逊EC2弹性IP地址,服务器实际上并不知道它与大多数其他服务器的IP。所以你需要告诉你的linux允许进程绑定到非本地地址。只需将以下行添加到/etc/sysctl.conf中,然后重新加载您的sysctl.conf。

但在亚马逊的Linux AMI bash: sysctl: command not found

回答

5

你可以删除IP部分,只是有这个?

listen 443; 

你只需要指定一个IP,如果你有分配给服务器的多个IP地址,并且希望nginx的听只有IP。

+2

AWS中的所有内容都使用NAT进行设置。只有一个私有IP直接对机器可见,并且如果您停止/启动实例,IP将会更改(如果您使用的是VPC,则您拥有更多控制权) – datasage 2013-03-26 13:00:10

相关问题