A
A
Andrey Mironov2018-05-29 12:10:15
Nginx
Andrey Mironov, 2018-05-29 12:10:15

How to use an external IP address in a Docker container with Nginx?

Hello, I will ask for help in setting up listening on a specific IP address in the Nginx configuration.
nginx.conf :

server {
    listen 91.218.229.77:80;
    server_name example.com;
}

Previously, I successfully used this address in the Nginx environment without Docker itself, now when I try to start the container, I get an error about address service denial:
nginx_1      | nginx: [emerg] bind() to 91.218.229.77:80 failed (99: Address not available)

/etc/sysconfig/network-scripts/ifcfg-eth1:4 :
DEVICE=eth1:4
BOOTPROTO=static
ONBOOT=yes
IPADDR=91.218.229.77
NETMASK=255.255.254.0

ifconfig :
eth1:4: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 91.218.229.77  netmask 255.255.254.0  broadcast 91.218.229.255
        ether 00:25:90:56:b6:7e  txqueuelen 1000  (Ethernet)
        device interrupt 16  memory 0xfb900000-fb920000

I suppose that I should somehow delegate it to Docker itself?)) Maybe those settings (eth1: 4) are considered insufficient for it and I need to supplement them with something?
Thank you very much)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
planc, 2018-05-29
@Elliemae

in nginx config
listen 0.0.0.0:80;
then in the docker forward this port to where you need
https://docs.docker.com/compose/compose-file/#ports

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question