Laradock mengekspos port nginx

0

Saya sudah mencoba mengekspos nginx port untuk dapat mengakses halaman dengan ip eksternal.

Saya sudah mencoba mengekspos port 80 dengan:

iptables -A INPUT -p tcp --dport 80 -j ACCEPT

Tapi tidak ada yang berubah:

tcp6       0      0 :::80                   :::*                    LISTEN      7008/docker-proxy

Dokumentasi Laradock tidak jelas tentang masalah ini.

Saya juga menemukan bahwa Anda dapat mengekspos port dengan perintah

docker run --expose=80 nginx

Tetapi selalu mengatakan tidak dapat menemukan gambar dan mulai membangunnya.

Deeeic
sumber
Baris apa yang Anda gunakan untuk menjalankan wadah laradock Anda? Menggunakan perintah buruh pelabuhan Anda akan memutar wadah nginx dan mengekspos port 80 dari wadah tertentu.
Seth
Saya menjalankannya dengan docker-compose up -d nginx mysql. Melihat ke opsi saya tidak melihat - mengekspos atau apapun yang berhubungan dengan port. Apakah saya harus berlari melalui buruh pelabuhan? Saya tidak keberatan itu hanya sepertinya tidak melihat gambar saya dan mulai membangun sendiri.
Deeeic
Yes, you're using a very complex setup. If you look at the compose file for the laradock installation you will find it's actually running multiple services. You'd have to define it for the individual service which ports should be exposed or rather published (which is likely what you want). Your first command is just related to your local firewall so I'm not sure how that'd fit it. It's a bit unclear what you're trying to do, what works and what isn't.
Seth
Yes that's what I need. So how would I expose it? I mean what kind of line should I add to docker-compose file? The reason for first line is to allow connection from external IP. It works with localhost, internal IP but not with external. If I remember correctly if you would install nginx normally without docker to access it from external IP you have to add iptables rule and it should change from ::::80 to 0.0.0.0:80. If I understand it correctly docker overrwrites iptable rules with its own, right?
Deeeic

Jawaban:

0

You're using a project which uses a quite complex docker setup. Docker compose is used to start a whole bunch of containers if you look at the compose file for the project.

Docker itself supports quite a few different networking modes and you might want to check out the docker documentation to learn about it. Especially the docker container networking article can be quite insightful as it explains the default networking behavior.

Have a look at the nginx configuration for that project and check the nginx entry and the env file for the project. You will find that compose file already contains a ports section that, according to the compose configuration documentation, publishes the port for your local network and uses bridged networking.

What you will need to do is either change the docker network configuration to suite your needs or change your host configuration to provide actual routing (e.g. 1 could be relevant) or, probably easier, run a reverse proxy for your docker application ... you could do this using a docker container.

Seth
sumber