Configure URLs with prefix in Mojolicious behind Reverse Proxy (ProxyPass)

后端 未结 3 1628
攒了一身酷
攒了一身酷 2021-01-05 21:21

I\'m looking for a reliable way to configure Mojolicious running behind an Apache reverse proxy under /app, so that url_for(\'/foo\') actually returns /ap

3条回答
  •  被撕碎了的回忆
    2021-01-05 21:55

    You should mount your application under required path.

    In your startup you should do:

    $r =  $app->routes;
    $r =  $r->any( '/api' )->partial( 1 );
    
    $r->get( '/test' );
    

    You should not configure specially your apache. When GET /api/test will come your app will get /api/test route. This route partially matched to /api and the rest route /test will be assigned into ->stash->{ path }.

    So rest routes will be checked against /test (source)

提交回复
热议问题