【问题标题】:Nginx error log - invalid local addressNginx 错误日志 - 无效的本地地址
【发布时间】:2016-08-11 14:40:39
【问题描述】:

我有一个 Amazon EC2 服务器设置,在端口 80 上使用 Nginx 1.8.1,在端口 8080 上使用 Apache 2.4。

我的 Nginx 错误日志中填满了无效的本地地址“www.domain.com:80”

有人可以建议如何解决此错误吗?

我的 /etc/nginx/sites-enabled 下的 domain.com 如下

server {
listen 80;
server_name domain.com www.domain.com;
root /home/domain/public_html/;
index index.php index.htm index.html;

location / {
            #try_files $uri $uri/ /index.php;
            #try_files $uri $uri/ $uri.php;
            try_files $uri $uri/ /index.php?/$request_uri;
}

location ~ \.php$ {
    proxy_bind $host:80;
    proxy_pass http://www.domain.com:8080;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    add_header X-Cache-Status $upstream_cache_status;

    # Cache configuration
    proxy_cache my-cache;
    proxy_cache_valid 10s;
    proxy_no_cache $cookie_PHPSESSID;
    proxy_cache_bypass $cookie_PHPSESSID;
    proxy_cache_key "$scheme$host$request_uri";
}

    # Disable Cache for the file type html, json
    location ~* .(?:manifest|appcache|html?|xml|json)$ {
            expires -1;
    }

    # Enable Cache the file 30 days
    location ~* .(jpg|png|gif|jpeg|css|mp3|wav|swf|mov|doc|pdf|xls|ppt|docx|pptx|xlsx)$ {
            proxy_cache_valid 200 120m;
            expires 30d;
            proxy_cache my-cache;
            #access_log off;
            add_header X-Cache-Status $upstream_cache_status;
    }

location ~ /\. {
    access_log off;
    log_not_found off;
    deny all;
}

}

我在 Apache 虚拟主机下的 domain.com 如下

<VirtualHost 172.31.xx.xxx:8080>
    DocumentRoot /home/domain/public_html/
    ServerName domaine.com
    ServerAlias www.domain.com n1.domain.com
    ErrorLog /home/domain/logs/error_log
    CustomLog /home/domain/logs/access_log combined
    <Directory /home/domain/public_html>
            Options -Includes -ExecCGI
            AllowOverride All
    </Directory>

【问题讨论】:

  • 你有proxy_bind $host:80;指令有什么特别的原因吗?如果没有,请将其删除,它应该会停止错误(请注意,如果您选择走那条路线,您绑定的地址必须是本地地址)
  • 我已经复制了 codeigniter 的 nginx 设置,除了日志中出现恼人的错误外,它运行良好。正如你所建议的,我删除了指令 proxy_bind $host:80 并且这个错误已经消失了。
  • 我明白了。将来我可以将其包含在问题的描述中。我很高兴能帮上忙。请接受它作为答案:)

标签: apache nginx amazon-ec2


【解决方案1】:

你有proxy_bind $host:80;指令有什么特别的原因吗?如果没有,请将其删除,它应该会停止错误(请注意,如果您选择走那条路线,您绑定的地址必须是本地地址)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-02
    • 2012-05-29
    相关资源
    最近更新 更多