【问题标题】:conflicting server name "localhost" warning on nginxnginx 上的冲突服务器名称“localhost”警告
【发布时间】:2016-08-24 12:46:49
【问题描述】:

我正在尝试在 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 上遇到连接被拒绝

可能出了什么问题?

【问题讨论】:

    标签: nginx https localhost


    【解决方案1】:

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

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

    应该在host 文件中看到行

    127.0.0.1 localhost
    0.0.0.0 localhost
    

    删除或修改第二个

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

    如果你这样运行,一定要正确配置

    【讨论】:

      猜你喜欢
      • 2020-04-04
      • 2017-02-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-15
      • 2012-07-10
      • 1970-01-01
      相关资源
      最近更新 更多