0

I run an Angular app rendered from a Symfony controller. My symfony application is based on http://localhost/portal and has a route on http://localhost/portal/shop/ (wich renders the Angular app).

My current nginx configuration works well for this url.

When I reach http://localhost/portal/shop/.* I want that nginx runs the Symfony app on the controller http://localhost/portal/shop/ and let the rest of the uri be handled by Angular routing.

My nginx knowledge are limited. Is that possible ? If yes, how can it be achieved?

My current location to handle /portal/shop is :

location /portal {
    root $projectroot/portal/web;
    rewrite ^/portal/?(.*)$ /app_dev.php/$1 break;
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $projectroot/portal/web/$fastcgi_script_name;
    fastcgi_param HTTPS off;
    fastcgi_pass php:9000;
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
}

Let me know if you need more of my config file. It's pretty big as it also handle an api section ;-)

Thank you for your help!

Drifter104
  • 3,773
  • 2
  • 25
  • 39
Flohw
  • 1
  • 1
  • Yes, it's possible and without more information I'd even say the config you posted "should work". Maybe it would be useful to update the question with a description of the problems you have encountered when trying that?encountered? – shevron Sep 26 '18 at 09:58
  • Sorry @shevron, I havn't seen your comment... Not used to stackexchange format... See my response below, I make it worked. I took the problem to a too deep level. Thank you! – Flohw Sep 27 '18 at 11:12

1 Answers1

0

Found a solution without nginx. My mind might be blocked at a certain point.

Based on the solution provided in this stackoverflow answer I made this:

class ShopController extends Controller {
    /**
     * @Route("/shop/{angularRoute}", name="shop", requirements={"angularRoute": ".*"})
     */
    public function __invoke() {
        return $this->render('shop.html');
    }
}
Flohw
  • 1
  • 1