title: nginx redirect all domain to another port but keep one domain for admin apps
body: <p>I try to setup a web server with Docker, so I will use the main domain of my server "server.domain.com" for admin use (server.domain.com/phpmyadmin, ect...) and I want to redirect all the other domain to an apache container who listen on port 81. 
  
  So I have this code on my <code>default.conf</code>:</p>
  
  <pre><code>server {
      listen 80;
      listen [::]:80 default_server;
  
      location / {
         proxy_pass  http://web/;
      }
  }
  </code></pre>
  
  <p><code>main.conf</code>:</p>
  
  <pre><code>server {
      listen 80;
      listen [::]:80;
  
      server_name server.domain.com;
  
      location /phpmyadmin/ {
         proxy_pass http://phpmyadmin/;
      }
  
      error_page   500 502 503 504  /50x.html;
      location = /50x.html {
          root   /usr/share/nginx/html;
      }
  }
  </code></pre>
  
  <p>(Updated conf)</p>
  
  <p>And my <code>nginx.conf</code>:</p>
  
  <pre><code>user  nginx;
  worker_processes  2;
  
  error_log  /var/log/nginx/error.log warn;
  pid        /var/run/nginx.pid;
  
  
  events {
      worker_connections  1024;
  }
  
  
  http {
      include       /etc/nginx/mime.types;
      default_type  application/octet-stream;
  
      log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                    '$status $body_bytes_sent "$http_referer" '
                    '"$http_user_agent" "$http_x_forwarded_for"';
  
      access_log  /var/log/nginx/access.log  main;
  
      sendfile        on;
      tcp_nopush     on;
  
      keepalive_timeout  65;
  
      gzip  on;
      gzip_comp_level   5;
      gzip_http_version 1.0;
      gzip_min_length   0;
      gzip_types        *;
      gzip_vary         on;
  
  
      include /etc/nginx/conf.d/*.conf;
      include /etc/nginx/sites/*;
  }
  </code></pre>
  
  <p>a part of ‘docker-compose.yml‘:</p>
  
  <pre><code>nginx:
      build: ./server/proxy
      ports:
          - "80:80"
      #volumes:
         #- nginx_conf:/etc/nginx/
      networks:
          - web_network
      depends_on:
          - web
          - phpmyadmin
          - panel
  </code></pre>
  
  <p>At this moment I use "depends_on" for use the name of the container on my config but you talk only about network so I think "depends_on" is not obliged ?</p>
  
  <p>But that gives me an error <code>connection refused</code>.
  If I replace the <code>127.0.0.1</code> by <code>server.domain.com</code> the first vhost not working and redirect to nginx webRoot.</p>
  
  <p>So I have no idea why ...</p>
  
  <p>Thank you !</p>