2

I'm more of a frontend guy (CSS, javascript) trying to expand my knowledge about backend (apache, proxies) (so try to be gentle) and I'm asking after serveral hours of documentation, trying different approaches but so far nothing worked. I'm aware that I might be oblivious to concepts that go without saying for someone knowing their way around backend.

I have this Yii2 application, with a module, working fine. I would like this module to be available at the root level of another domain, on the same machine.

From everything I've read, the following code, placed in vhosts of my apache, should work:

<VirtualHost *:80>
    ServerName buletin
    ProxyPass / http://bdc/ik2/frontend/web/buletin/default/ 
    ProxyPassReverse / http://bdc/ik2/frontend/web/buletin/default/ 
</VirtualHost>

I'm expecting to see the default action of my module when I go to http://buletin.

What am I missing?

tao
  • 82,996
  • 16
  • 114
  • 150
  • where is placed the module? in frontend/web/buletin/default or in frontend/buletin/default? – ScaisEdge Dec 19 '15 at 20:58
  • It's placed in `common/modules/buletin`, because i has components i need in backend. It's a typical Yii2 module setup. The only thing I changes was set it's view path to the theme `/views` folder but it's all working good on the "main" site – tao Dec 19 '15 at 20:59
  • have you pretty url and scriptName false in confi/main.php ? – ScaisEdge Dec 19 '15 at 21:01
  • No. `'enablePrettyUrl' => true` and I never set up `showScriptName`. Should I set it to false? – tao Dec 19 '15 at 21:03
  • then is false .. you don't use frontend/web/index.php/controller/action .. right? – ScaisEdge Dec 19 '15 at 21:09
  • Have you error? what's happen ? – ScaisEdge Dec 19 '15 at 21:10
  • Ok, I got it to work. The problem was I wasn't logged in on this website and it was redirecting me to `/site/login`, which meant `/buletin/default/site/login`, which did not exist. Once I fixed this, all works as expected. Should I delete the question or do you think it has value for someone trying to setup a module to load at root level? I also had to add exceptions to the ProxyPass for `theme`, `img`, `assets` and `debug`. But it's working now :). Sorry for wasting your time. – tao Dec 19 '15 at 21:25
  • 1
    Don't delete.. post your solution as answer. could be someone have the same problem .. – ScaisEdge Dec 19 '15 at 21:27

1 Answers1

2

Ok, in case someone else has the same problem, just double check all of your app's redirects and make sure everything works inside your module. If it doesn't, either add it as exception to the ProxyPass i.e.:

ProxyPass /ik2/frontend/web/themes/ http://bdc/ik2/frontend/web/themes/
ProxyPass /ik2/frontend/web/img/ http://bdc/ik2/frontend/web/img/
ProxyPass /ik2/frontend/web/assets/ http://bdc/ik2/frontend/web/assets/

#(all exceptions need to be placed above general ProxyPass and ProxyPassReverse)

or make it available inside your module.

In my case, I wasn't logged in the "new" website and it was redirecting me to /site/login, which did not exist (no buletin/default/site/login). Once I handled it and I added the exceptions for the assets and images to the ProxyPass, it's all working smoothly.

tao
  • 82,996
  • 16
  • 114
  • 150