404 page not found on nginx webserver when hosted on VPS

When I host my kafka server on vps and add the nginx server for the control center authentication, I get the error 404 page not found. However this same setup works fine on my local machine when I change the nginx.conf file and replcae evey ip address with my localhost. I am using docker containers and I have 5 docker containers 2 of them are kafka brokers, 1 is zookeepr, 1 is the control center and 1 is the nginx server. Everything is working fine, the niginx logs is saying that its ready to use.

this is my nginx.conf file

user nginx;
worker_processes auto;
pid /run/nginx.pid;

events {
    worker_connections 1024;
}

http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    # SSL settings
    ssl_certificate /etc/nginx/ssl/ssl_cert.pem;
    ssl_certificate_key /etc/nginx/ssl/ssl_cert.key;

    # Gzip Settings (optional)
    gzip on;

    server {
        listen 443 ssl;
        server_name <VPS_ADDRESS>;  # Change to your local IP or hostname if needed

        # Proxy settings for Control Center
        location / {
            auth_basic "Restricted Access";
            auth_basic_user_file /etc/nginx/.htpasswd;

            proxy_pass http://control-center:9021;  # Forward requests to Control Center
            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-Proto $scheme;

        }

        # Error page for 404
        error_page 404 /404.html;
    }

    server {
        listen 80;
        server_name <VPS_ADDRESS>;  # Change to your local IP or hostname if needed

        # Redirect all HTTP to HTTPS
        return 301 https://$host$request_uri;
    }
}

and these are docker containers for nginx and control center:


  control-center:
    image: confluentinc/cp-enterprise-control-center:7.4.0
    hostname: control-center
    container_name: control-center
    depends_on:
      - zookeeper
      - broker1
      - broker2
    ports:
      - "9021:9021"  # Control Center UI port
    environment:
      CONTROL_CENTER_BOOTSTRAP_SERVERS: 'broker1:29092,broker2:29093'
      CONTROL_CENTER_ZOOKEEPER_CONNECT: 'zookeeper:2181'
      CONTROL_CENTER_CONNECT_CONNECT_CLUSTER: 'localhost:8083'
      CONTROL_CENTER_KSQL_KSQLDB1_URL: "http://ksqldb-server:8088"
      CONTROL_CENTER_SCHEMA_REGISTRY_URL: "http://schema-registry:8081"
      CONTROL_CENTER_REPLICATION_FACTOR: 1
      CONTROL_CENTER_INTERNAL_TOPICS_PARTITIONS: 1
      CONTROL_CENTER_MONITORING_INTERCEPTOR_TOPIC_PARTITIONS: 1
      CONFLUENT_METRICS_TOPIC_REPLICATION: 1
      CONTROL_CENTER_SSL_KEYSTORE_LOCATION: '/etc/ssl/keystore.jks'  # Path to keystore in the container
      CONTROL_CENTER_SSL_KEYSTORE_PASSWORD: 'key_stroe_pw'  # Keystore password
      CONTROL_CENTER_SSL_TRUSTSTORE_LOCATION: '/etc/ssl/truststore.jks'  # Path to truststore in the container
      CONTROL_CENTER_SSL_TRUSTSTORE_PASSWORD: 'trust_store_pw'  # Truststore password

    volumes:
      - ./keystore.jks:/etc/ssl/keystore.jks:ro  # Mount the keystore into the container
      - ./truststore.jks:/etc/ssl/truststore.jks:ro  # Mount the truststore into the container (if applicable)
    networks:
      - confluent
    healthcheck:
      test: ["CMD", "curl", "-f", "https://localhost:9021"]
      interval: 30s
      timeout: 10s
      retries: 5

  nginx:
    image: nginx:latest
    container_name: nginx
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf:ro  # NGINX config
      - ./htpasswd:/etc/nginx/.htpasswd:ro  # Password file for authentication
      - ./ssl:/etc/nginx/ssl:ro  # Mount the SSL certificates
    ports:
      - "443:443"  # Expose SSL on port 443
      - "8080:8080"  # Redirect HTTP to HTTPS
    depends_on:
      - control-center
    networks:
      - confluent

I can access the control center directly from my local machine through this <VPS_ADDRESS>:9021 but I want an authentication enabled so that when I access this http://<VPS_ADDRESS> i get a prompt to add username and password and the redirect to control center.

I have tried to access the control center from nginx container, I am getting 200 response message on curl http://control-center:9021

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật