LXC and Docker issue with Nginx proxy pass

DeviC3

New Member
Apr 7, 2022
3
0
1
On one of my lxc containers I installed nginx (as usual systemd service) and on docker I have web image which have port 3000 opened.
On vhost side proxy pass is configured like this
Code:
server {
    listen 80;
    listen [::]:80;

    server_name example.com;

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_set_header   Host $host;
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Host $server_name;
        proxy_set_header   X-Forwarded-Proto $scheme;
    }

}

But unfortunately nginx shows 502 with error log lines
Code:
connect() failed (111: Connection refused) while connecting to upstream

On any VM there are no problem with this I'm using Proxmox 7.2-7 version
Is there any issues with this type of communication ?
 
Are nginx and the webservice running in two separate containers? Because then using 127.0.0.1 as IP would point to the local docker container, not the host. You need to specify the IP of the docker container instead (usually smth like 172.16.x.x or an alias (name of the container)).
 
So you have docker running with both the webservice and nginx in the VM? Because then it would still pose a problem using 127.0.0.1 as the IP. You can check the name of the container via docker ps -a and then try using the name of the container (in the rightmost column) instead of the IP address. For the future it might be smart to assign a fixed name to the web service container then, so it works after restarting the container.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!