'configure nginx reverse proxy inside docker container

I have a docker contaniner running on a Debian Virtual machine. The docker container respond locally to http://192.168.1.5.

In the same Debian Virtual machine I added nginx reverse proxy:

version: '3'

services:
  webserver:
    image: nginx:latest
    container_name: nginx
    ports:
      - 80:80
      - 443:443
    restart: always
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf

this is my conf file:

#/etc/nginx/nginx.conf

events {
    worker_connections  1024;
}

http {
   
 server {

        listen 80;

        server_name spa.ddns.net;

        location /ha {

            proxy_pass http://192.168.1.5:8123;

        }
    }
}

I want access from internet to http://192.168.1.5:8123, the port forwarding and the firewall routes are ok, I have try an other web server on my LAN and it works ( python3 -m http.server 80 )

If I try to connect via browser nothing happens. If I try with curl he say "not found"

$ curl http://spa.ddns.net/ha
404: Not Found%  


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source