Docker Community Forums

Share and learn in the Docker community.

Reverse Proxy and 400 Bad Request error

HI

I have 1 Problem with ONE of my docker containers. I can access 3 of 4 with the help of the reverse proxy , but the last one won’t work

First i start a reverse Proxy

version: '3.7'
services:
  nginx-proxy-live:
    hostname: nginx-proxy-live.${var_base}
    container_name: nginx-proxy-live.${var_base}
    image: jwilder/nginx-proxy
    ports:
        - "${var_http_proxyport_live}:80"
    volumes:
        - /var/run/docker.sock:/tmp/docker.sock:ro
        
  surrounding:
    hostname: surrounding-live.${var_base}
    container_name: surrounding-live.${var_base}
    image: nginx
    restart: always
    environment:  
    - VIRTUAL_HOST=surrounding-live.${var_base}
       
networks:
    default:
      external:
        name: nginx-proxy-live

Then I start my BASE environment

version: '3.7'
services:
    mariadb:
        image: mariadb:10.1
        restart: always
        hostname: db-${var_server_name}
        container_name: db-${var_server_name}
        ports:
            - ${var_sql_port}:3306
        environment:
            TZ: "Europe/Rome"
            MYSQL_ALLOW_EMPTY_PASSWORD: "no" 
            MYSQL_ROOT_PASSWORD: ${var_db_rootpasswd}

    phpmyadmin:
        image: phpmyadmin/phpmyadmin
        restart: always
        hostname: phpmyadmin-${var_server_name}
        container_name: phpmyadmin-${var_server_name}
        environment:  
          - VIRTUAL_HOST=phpmyadmin-${var_server_name}
          - PMA_HOST=db-${var_server_name}
        links:
            - mariadb
    mailhog:
        image: mailhog/mailhog
        hostname: mailhog-${var_server_name}
        container_name: mailhog-${var_server_name}
        restart: always
        environment:  
          - VIRTUAL_HOST=mailhog-${var_server_name}
          - VIRTUAL_PORT=8025
        healthcheck:
         test: echo | telnet 127.0.0.1 25

networks:
  default:
    external:
      name: nginx-proxy-${var_network_suffix}

After that the Project APMS

version: '3.7'
services:
    www-php-apache:
        build:
            context: ./../_bpmspace_base
        restart: always
        hostname: server-${var_server_name}
        container_name: server-${var_server_name}
        environment:  
        - VIRTUAL_HOST=server-${var_server_name}
        - NODE_ENV=${var_environment_i}
networks:
  default:
    external:
      name: nginx-proxy-${var_network_suffix}

Finally can see the following dockers up and running

CONAINER ID        IMAGE                                     COMMAND                  CREATED             STATUS                             PORTS                       NAMES
eb1097f72577        project_live_apms2vcapme_www-php-apache   "docker-php-entrypoi…"   8 seconds ago       Up 6 seconds                       80/tcp                      server-LIVE_APMS2.vcap.me
8a792ae97e43        phpmyadmin/phpmyadmin                     "/docker-entrypoint.…"   11 seconds ago      Up 9 seconds                       80/tcp                      phpmyadmin-LIVE_BASE.vcap.me
db85b3f9e00c        mariadb:10.1                              "docker-entrypoint.s…"   13 seconds ago      Up 10 seconds                      0.0.0.0:33060->3306/tcp     db-LIVE_BASE.vcap.me
78f74919ca54        mailhog/mailhog                           "MailHog"                13 seconds ago      Up 10 seconds (health: starting)   1025/tcp, 8025/tcp          mailhog-LIVE_BASE.vcap.me
59eb38eaad06        nginx                                     "nginx -g 'daemon of…"   16 seconds ago      Up 14 seconds                      80/tcp                      surrounding-live.vcap.me
5951b93b2f9e        jwilder/nginx-proxy                       "/app/docker-entrypo…"   16 seconds ago      Up 14 seconds                      0.0.0.0:8087->80/tcp        nginx-proxy-live.vcap.me

The Proxy is listing to port 8087 - nslookup *.vcap.me always gives 127.0.0.1 back
From the Browser I can access

BUT I get an BAD REQUEST when I try to access

  • http://server-LIVE_APMS2.vcap.me:8087

Error Messages in the Browser

Your browser sent a request that this server could not understand.

Additionally, a 400 Bad Request error was encountered while trying to use an ErrorDocument to handle the request.

Apache/2.4.25 (Debian) Server at www-LIVE_APMS2.vcap.me Port 8087

When I bash into the container from CLI

docker exec -it server-LIVE_APMS2.vcap.me /bin/bash

and do

wget localhost`  

I get

root@server-LIVE_APMS2:~# wget localhost
--2019-10-08 13:53:21--  http://localhost/
Resolving localhost (localhost)... 127.0.0.1, ::1
Connecting to localhost (localhost)|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 16 [text/html]
Saving to: 'index.html'

index.html                                                  100%[========================================================================================================================================>]      16  --.-KB/s    in 0s

2019-10-08 13:53:21 (1.86 MB/s) - 'index.html' saved [16/16]

ANY IDEAS? Thanks rob

The 400 Bad Request error is an HTTP status code indicates that the request you sent to the webserver was malformed , in other words, the data stream sent by the client to the server didn’t follow the rules. It means that the request itself has somehow incorrect or corrupted and the server couldn’t understand it. The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method . Therefore, it prevents the website from being properly displayed. There are a number of different causes for a 400 Bad Request Error . It might be a malformed request syntax, invalid request message framing, or deceptive request routing . In most cases, the problem is on the website itself, and there’s not much you can do about that. To fix a 400 Bad Request error it is best to start diagnosing the issue from the client side itself. Complete the steps outlined in this section to help diagnose and correct the error.

  • Check for errors in the URL.
  • Clear Browser Cache and cookies.
  • Clear DNS Cache.
  • Check your File upload Size.
  • Deactivate Browser Extensions.
  • Contact the site owner to report the 404 error.

Thank you. This post was very helpful to me. Christian beliefs license for sin