如何配置Nginx在vNIC IP上监听?

问题描述 投票:0回答:1

我在Nginx服务器上运行了一个配置为

server
{
 listen 1.2.3.4:8200;
 ...
}

但我得到一个错误信息说

nginx: [emerg] bind() to 1.2.3.4:8200 failed  
errorDetail": "99- Cannot assign requested address

但这是我想要的Nginx配置的样子,我在Linux docker容器上设置了VNic,inet地址为 "1.2.3.4"。我在Linux的docker容器上设置了一个VNic,inet地址为 "1.2.3.4"。

在搜索一些链接时 - 看起来像 You can't bind to an IP address not assigned to your computer.但这个IP是通过vNIC分配的!而且我只在Docker容器设置中看到这个错误。

另外,我只在Docker容器设置中看到这个错误。Nginx配置在我的Azure Linux虚拟机中加载正常。我在Docker设置中可能缺少任何设置?

我使用docker-compose来创建docker容器,而我的 dockerCompose.yaml 文件看起来像这样

version: "3"
services:
  dev:
    image: <MyImageName>
    build:
      dockerfile: docker/Dockerfile-build
      context: .
    ports:
      - 8080:80
      - 8200:8200
      - "127.0.0.1:8083:22"
    working_dir: /azure
    entrypoint: /bin/bash
    cap_add:
      - NET_ADMIN
docker nginx containers nginx-config
1个回答
0
投票

netstat -ntlp 显示的是哪个进程持有 IP:port所以我就用 IP:port,并重新加载nginx。

© www.soinside.com 2019 - 2024. All rights reserved.