2

I have to run a container running nginx as a reverse proxy using podman.

Dockerfile is as follows:

FROM nginx

COPY nginx/* /etc/nginx/

Where basically I have a default.conf file under conf.d which is like this:

server {
listen       80;
server_name  my-server;

client_max_body_size 200M;

location / {
    root /usr/share/nginx/html;
}

location /api {
    proxy_set_header X-FORWARDED-FOR $remote_addr;
    proxy_pass http://backend:3300/api;
}

error_page  404              /;

# redirect server error pages to the static page /50x.html
#
error_page   500 502 503 504  /50x.html;
location = /50x.html {
    root   /usr/share/nginx/html;
}

}

where backend is an alias for another container with a rest server running on the same network that contains the proxy.

I setup the network with the command:

podman create custom-network

then I run the following command:

podman run -d --name=frontend -p 80:80 --network=custom-network:alias=frontend -v ./www:/usr/share/nginx/html -v ./logs:/var/log/nginx localhost/my-www:latest 

At this point everything is up and running and I can open my application from the browser in the same machine, but it is unreachable from another computer on the same network.

I already turned off windows firewall on every network, but still nothing.

Is there a podman command or a configuration tweak that make nginx container reachable from outside?

Pierre.Vriens
  • 7,225
  • 14
  • 39
  • 84

1 Answers1

2

I ran into this same issue on windows and since you mentioned windows firewall I am assuming you are also running it.

I noticed that you did not mention any portmapping.

Get the ip of your podman vm. podman machine ssh and then an ifconfig. Then you just map your port like below to your vm ip and your requests from outside should work.

netsh interface portproxy add v4tov4 listenport=<hostport> listenaddress=0.0.0.0 connectport=<containerPORT> connectaddress=172.26.29.96

eddyizm
  • 136
  • 4