Cannot access nginx url within container

I have the following setup

  1. Vagrant box with docker installed

  2. My Docker container will run a command from within the container, but not with ENTRYPOINT
  3. Running Babel on NodeJS5.12.0 image inside the Docker for Windows
  4. How can I use the internal ip adress of a container as an environment variable in Docker
  5. mounting data volumes to another container
  6. How to run mvn sonar:sonar using jhipster and sonar in docker containers
  7. Will spawned processes inside docker container utilize all cpu cores on container host by default?
  8. Docker container up and running and working

However I cannot access from my host one of the urls specified in nginx config

I can access the grafana one

My vagrant file

Vagrant.configure("2") do |config|
    config.vm.box = "dockerNoel"
    config.vm.box_url = "http://files.vagrantup.com/precise64.box"
    config.vm.provider :virtualbox do |virtualbox|
        # allocate 1024 mb RAM
        virtualbox.customize ["modifyvm", :id, "--memory", "2048"] 
        # allocate max 50% CPU
        virtualbox.customize ["modifyvm", :id, "--cpuexecutioncap", "50"]
      end
    # we'll forward the port 8000 from the VM to the port 8000 on the host (OS X)
    config.vm.network :forwarded_port, host: 80, guest: 80
    config.vm.network :forwarded_port, host: 8125, guest: 8125, protocol: 'udp'
    config.vm.network :forwarded_port, host: 8126, guest: 8126
    config.vm.network :forwarded_port, host: 9200, guest: 9200
    config.vm.network :forwarded_port, host: 9300, guest: 9300

    config.vm.provision "docker"
end

my nginx config file

daemon off;
user www-data;
worker_processes 1;
pid /var/run/nginx.pid;

events {
  worker_connections 1024;
}

http {
  sendfile on;
  tcp_nopush on;
  tcp_nodelay on;
  keepalive_timeout 65;
  types_hash_max_size 2048;
  server_tokens off;

  server_names_hash_bucket_size 32;

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

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

  gzip on;
  gzip_disable "msie6";

  server {
    listen 80 default_server;
    server_name _;
    location / {
      root /src/grafana;
      index index.html;
    }
    location /graphite/ {
        proxy_pass                 http://127.0.0.1:8000/;
        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;
        proxy_set_header           X-Forwarded-Server  $host;
        proxy_set_header           X-Forwarded-Host  $host;
        proxy_set_header           Host  $host;

        client_max_body_size       10m;
        client_body_buffer_size    128k;

        proxy_connect_timeout      90;
        proxy_send_timeout         90;
        proxy_read_timeout         90;

        proxy_buffer_size          4k;
        proxy_buffers              4 32k;
        proxy_busy_buffers_size    64k;
        proxy_temp_file_write_size 64k;
    }

    location /elasticsearch/ {
        proxy_pass                 http://127.0.0.1:9200/;
        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;
        proxy_set_header           X-Forwarded-Server  $host;
        proxy_set_header           X-Forwarded-Host  $host;
        proxy_set_header           Host  $host;

        client_max_body_size       10m;
        client_body_buffer_size    128k;

        proxy_connect_timeout      90;
        proxy_send_timeout         90;
        proxy_read_timeout         90;

        proxy_buffer_size          4k;
        proxy_buffers              4 32k;
        proxy_busy_buffers_size    64k;
        proxy_temp_file_write_size 64k;
    }
  }

   server {
    listen 8888;

    location / {
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_redirect off;
      proxy_pass http://localhost:5000/;
     }

    location /static/ {
      include       /etc/nginx/mime.types;
      default_type  application/octet-stream;
      root /cabot/;
    }
  }

  server {
    listen 81 default_server;
    server_name _;

    open_log_file_cache max=1000 inactive=20s min_uses=2 valid=1m;

    location / {
        proxy_pass                 http://127.0.0.1:8000;
        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;
        proxy_set_header           X-Forwarded-Server  $host;
        proxy_set_header           X-Forwarded-Host  $host;
        proxy_set_header           Host  $host;

        client_max_body_size       10m;
        client_body_buffer_size    128k;

        proxy_connect_timeout      90;
        proxy_send_timeout         90;
        proxy_read_timeout         90;

        proxy_buffer_size          4k;
        proxy_buffers              4 32k;
        proxy_busy_buffers_size    64k;
        proxy_temp_file_write_size 64k;
    }

    add_header Access-Control-Allow-Origin "*";
    add_header Access-Control-Allow-Methods "GET, OPTIONS";
    add_header Access-Control-Allow-Headers "origin, authorization, accept";

    location /content {
      alias /var/lib/graphite/webapp/content;
    }

    location /media {
      alias /usr/share/pyshared/django/contrib/admin/media;
    }
  }
}

When I browse from host to http://127.0.0.1 it works
But for http://127.0.0.1/graphite/ I get 404 not found

When I use curl from within guest vagrant box they both work

I believe I am doing something silly regarding networking but cant figure it out

  • Docker: user namespace remapping not working although enabled for daemon
  • Mesos + Marathon : json: cannot unmarshal string into Go value of type []string
  • Ansible and restarting a docker service
  • How to connect to mysql running on docker using Sequel Pro
  • ingensi/play-framework image repetitive downloads
  • Cannot make/remove an entry for the specified session - cron
  • One Solution collect form web for “Cannot access nginx url within container”

    You have an ending slash in your proxy_pass. This means /graphite/ is passed to the backend. I suspect graphite is running from the root, so on the backend the uri is not found.

    See the documentation on proxy_pass: http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.