冲突的服务器名称" localhost"关于nginx的警告

时间:2016-08-24 12:46:50

标签: nginx https localhost

我正在尝试在linux cntainer上为我的localhost设置nginx 这是配置

## server configuration
server {
    listen 443 ssl;
    listen 80 ;
    ## add ssl entries when https has been set in config
    ssl_certificate      /etc/ssl/cert.pem;
    ssl_certificate_key  /etc/ssl/key.pem;
    ssl_session_cache shared:SSL:1m;
    ssl_prefer_server_ciphers   on;

    server_name localhost;
    if ($http_x_forwarded_proto = '') {
        set $http_x_forwarded_proto  $scheme;
    }
    ## Application specific logs
    ## access_log /var/log/nginx/localhost-access.log timing;
    ## error_log /var/log/nginx/localhost-error.log;
    rewrite ^/$ /artifactory/webapp/ redirect;
    rewrite ^/artifactory/?(/webapp)?$ /artifactory/webapp/ redirect;
    location /artifactory/ {
    proxy_read_timeout  900;
    proxy_pass_header   Server;
    proxy_cookie_path ~*^/.* /;
    proxy_pass         http://localhost:8081/artifactory/;
    proxy_set_header   X-Artifactory-Override-Base-Url $http_x_forwarded_proto://$host:$server_port/artifactory;
    proxy_set_header    X-Forwarded-Port  $server_port;
    proxy_set_header    X-Forwarded-Proto $http_x_forwarded_proto;
    proxy_set_header    Host              $http_host;
    proxy_set_header    X-Forwarded-For   $proxy_add_x_forwarded_for;
    }
}

## server configuration
server {
    listen 6555 ssl;


    server_name localhost;
    if ($http_x_forwarded_proto = '') {
        set $http_x_forwarded_proto  $scheme;
    }
    ## Application specific logs
    ## access_log /var/log/nginx/localhost-access.log timing;
    ## error_log /var/log/nginx/localhost-error.log;
    rewrite ^/(v1|v2)/(.*) /artifactory/api/docker/docker-virtual/$1/$2;
    client_max_body_size 0;
    chunked_transfer_encoding on;
    location /artifactory/ {
    proxy_read_timeout  900;
    proxy_pass_header   Server;
    proxy_cookie_path ~*^/.* /;
    proxy_pass         http://localhost:8081/artifactory/;
    proxy_set_header   X-Artifactory-Override-Base-Url $http_x_forwarded_proto://$host:$server_port/artifactory;
    proxy_set_header    X-Forwarded-Port  $server_port;
    proxy_set_header    X-Forwarded-Proto $http_x_forwarded_proto;
    proxy_set_header    Host              $http_host;
    proxy_set_header    X-Forwarded-For   $proxy_add_x_forwarded_for;
    }
}

在我retsrat nginx之后,我收到以下错误

nginx: [warn]nginx: [warn] conflicting server name "localhost" on 0.0.0.0:80, ignored

"本地主机"在0.0.0.0:80,忽略

当我导航到浏览器时,我在localhost上拒绝连接:443

可能出现什么问题?

1 个答案:

答案 0 :(得分:0)

您的服务器无法将您的域名 localhost 解析为一个 IP 地址

您可能在 hosts 文件中有重复的本地虚拟主机名条目

应该在 host 文件中看到行

127.0.0.1 localhost
0.0.0.0 localhost

删除或修改第二个

这个问题也可能是由于运行 unbound 等虚拟 DNS 服务引起的

如果您正在运行,请务必正确配置