title: Trying to dockerize Spring Boot and Laravel apps with Nginx
body: <p>Basically I do have an app where I have 2 backend projects.</p>
  <p>The first one is a Spring Boot project where I have some recommendations algorithms which I want Angular to execute.</p>
  <p>The second one is a Laravel project which contains some endpoints for the database (users, items, etc.)</p>
  <p>The way Angular is going to communicate with Spring Boot is via WebSocket, so I need some routes to get the data.</p>
  <p>The way Angular is going to communicate with Laravel is via API Rest protocol, some basic stuff.</p>
  <p>This is the docker-compose I have for the app (I don't know if ports for Nginx are right, but I don't know how to do it)</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>version: '3'
  networks:
    laravel:
  
  services:
    nginx:
      image: nginx:stable-alpine
      container_name: nginx
      ports:
        - "80:80"
        - "8090:8090"
      volumes:
        - .:/var/www/html
        - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
      depends_on:
        - php
        - mysql
      networks:
        - laravel
  
    mysql:
      image: mysql:5.7.22
      container_name: mysql
      tty: true
      ports:
        - "3306:3306"
      volumes:
        - ./docker/mysql:/var/lib/mysql
      environment:
        MYSQL_DATABASE: ''
        MYSQL_USER: ''
        MYSQL_PASSWORD: ''
        MYSQL_ROOT_PASSWORD: ''
      networks:
        - laravel
  
    php:
      build:
        context: .
        dockerfile: ./docker/Dockerfile
      container_name: php
      volumes:
        - .:/var/www/html
        - ./machine-learning/RecommendationSystem:/app
        - "./machine-learning/.m2:/.m2"
      ports:
        - "9000:9000"
      networks:
        - laravel
  
    maven:
      build:
        context: .
        dockerfile: ./docker/java/Dockerfile
      container_name: java
      volumes:
        - ./machine-learning:/usr/src/machine-learning
      depends_on:
        - php
        - mysql
      networks:
        - laravel</code></pre>
  </div>
  </div>
  </p>
  <p>Also, here it is my Nginx conf file:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>upstream springboot
  {
     keepalive 32;
     server localhost:8090 fail_timeout=0;
  }
  
  server {
      listen 80 default_server;
      listen [::]:80 default_server;
      server_name localhost;
  
      root /var/www/html/public;
      index index.php index.html index.htm;
  
      location / {
           try_files $uri $uri/ /index.php$is_args$args;
      }
  
      location ~ \.php$ {
          try_files $uri /index.php =404;
          fastcgi_pass php:9000;
          fastcgi_index index.php;
          fastcgi_buffers 16 16k;
          fastcgi_read_timeout 300;
          fastcgi_buffer_size 32k;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          include fastcgi_params;
      }
  
      location /machine-learning {
          proxy_pass http://localhost:8090/;
          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-Host   $host;
          proxy_set_header    X-Forwarded-Server $host;
          proxy_set_header    X-Forwarded-Port   $server_port;
          proxy_set_header    X-Forwarded-Proto  $scheme;
      }
  
     error_log /var/log/nginx/error.log;
     access_log /var/log/nginx/access.log main;
  }</code></pre>
  </div>
  </div>
  </p>
  <p>When I execute mvn package inside the container and then execute curl --verbose http://localhost:8090, it shows me the content I am expecting (a basic hello world message), so I guess the Nginx conf file is correct. When I access this same route in my web browser, I receive the: &quot;The connection was reset&quot; message.</p>
  <p>Anyone could help me?</p>