0

Can someone point me to a NGINX Reverse Proxy container how to for podman? Most of the docs I find are for docker. Ideally I would like Nginx to act as reverse proxy so I can have multiple contains on my host nginx would proxy to the proper container base based on url. Keep in mind this is for internal use to my private nework. I currently only have 1 contain but plan to add more.

For example I have a container for my home page home.xxx. I would like nginx to proxy to my home page home so I don't have to type home.foo.org:8081

Any help is appreciated.

1
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer.
    – Community Bot
    Commented Mar 4, 2023 at 16:44

1 Answer 1

0

If you have your application running at home.foo.org:8081, you can do the following:

  1. create a folder nginx and cd into it
  2. create a default config and a config for your app
cat << EOF > default.conf
server {
    listen       80;
    listen  [::]:80;
    server_name  localhost;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

}
EOF

cat << EOF > app.conf
server {
  listen 80;
  server_name home.foo.org;

  location / {
    proxy_pass http://<your_ip>:8081;
  }
}
EOF
  1. start nginx: podman run --name=nginx -p 80:80 -v <your_path>/nginx:/etc/nginx/conf.d:Z -d docker.io/library/nginx

Voila, now you have application available on HTTP. Do note that if you want SSL/TLS you should look for port 443 and change accordingly.

1
  • If the backend web servers can listen on Unix sockets, it is possible to improve security by running the Nginx reverse proxy with podman run --network=none .... I've previously verified that it works. Unfortunately I didn't document the details. I also wrote some documentation about Nginx + Podman + socket activation in github.com/eriksjolund/podman-nginx-socket-activation .That example does not use Nginx as a reverse proxy but you could use the same technique for Nginx as reverse proxy. Commented May 31, 2023 at 4:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .