Browse Source

AppKernel updated

Guillermo Espinoza 7 years ago
parent
commit
fbb1c44329
1 changed files with 22 additions and 5 deletions
  1. 22 5
      app/AppKernel.php

+ 22 - 5
app/AppKernel.php

@@ -49,13 +49,11 @@ class AppKernel extends Kernel
             $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
             $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
             $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
-
-            if ('dev' === $this->getEnvironment()) {
-                $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
-                $bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle();
-            }
+            $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
         }
 
+        $bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle();
+
         return $bundles;
     }
 
@@ -78,4 +76,23 @@ class AppKernel extends Kernel
     {
         $loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
     }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
+    {
+        if (false === $this->booted) {
+            $this->boot();
+        }
+        // se puede sacar la variable nginx-proxy porque es el nombre del docker y puede variar
+        // con REMOTRA_ADDR obtengo el mismo valor (http://symfony.com/doc/current/deployment/proxies.html)
+        //gethostbyname("nginx-proxy") == $request->server->get('REMOTE_ADDR')
+        if ($this->container->hasParameter("nginx_name")) {
+            Request::setTrustedProxies(
+                array('127.0.0.1', $this->container->getParameter("nginx_name")),
+                Request::HEADER_X_FORWARDED_FOR);
+        }
+        return parent::handle($request, $type, $catch);
+    }
 }