apache reverse proxy in subdirectory not working #36

Closed
opened 2026-02-04 16:42:09 +03:00 by OVERLORD · 4 comments
Owner

Originally created by @newhinton on GitHub (Oct 4, 2020).

I use a simple apache vhost to host planka in a subdirectory:

example.com/todo

i used docker compose, and set BASE_URL to 'example.com/todo'

i can load the main planka app (the html loads, but scripts still reference 'example.com'). It seems if a subdirectory in base_url is not used. Is there a way to make this work?

Apache vhost config: (the relevant part)

<Location /todo >
            ProxyPass http://127.0.0.1:3000
            ProxyPassReverse http://127.1.0.1:3000
            ProxyPreserveHost On
</Location>
Originally created by @newhinton on GitHub (Oct 4, 2020). I use a simple apache vhost to host planka in a subdirectory: example.com/todo i used docker compose, and set BASE_URL to 'example.com/todo' i can load the main planka app (the html loads, but scripts still reference 'example.com'). It seems if a subdirectory in base_url is not used. Is there a way to make this work? Apache vhost config: (the relevant part) ``` <Location /todo > ProxyPass http://127.0.0.1:3000 ProxyPassReverse http://127.1.0.1:3000 ProxyPreserveHost On </Location> ```
OVERLORD added the enhancement label 2026-02-04 16:42:09 +03:00
Author
Owner

@meltyshev commented on GitHub (Oct 5, 2020):

Hi! Currently, subdirectories are not supported, but you can modify one file to achieve this: add a "homepage": "/todo" setting to the client/package.json. Then docker build -t planka . in the root folder. Now you can change the image in docker-compose.yml from meltyshev/planka:latest to planka.

@meltyshev commented on GitHub (Oct 5, 2020): Hi! Currently, subdirectories are not supported, but you can modify one file to achieve this: add a `"homepage": "/todo"` setting to the `client/package.json`. Then `docker build -t planka .` in the root folder. Now you can change the image in `docker-compose.yml` from `meltyshev/planka:latest` to `planka`.
Author
Owner

@newhinton commented on GitHub (Oct 5, 2020):

Thank you for your answer! It worked, as the scripts and resources are loading, however, i just get a 'page not found' message. It seems that sails now answers the requests as expected, but internally the routes are not updated.

Is this a simple fix like the package.json edit, or should i wait until it is properly supported?

@newhinton commented on GitHub (Oct 5, 2020): Thank you for your answer! It worked, as the scripts and resources are loading, however, i just get a 'page not found' message. It seems that sails now answers the requests as expected, but internally the routes are not updated. Is this a simple fix like the package.json edit, or should i wait until it is properly supported?
Author
Owner

@meltyshev commented on GitHub (Oct 5, 2020):

Can you try to change the line in client/src/history.js from export default createBrowserHistory(); to export default createBrowserHistory({ pathname: '/todo' });. Also, there could be some issues with socket connection, if that happens - try to change the line in Dockerfile from RUN npm run build to RUN REACT_APP_SERVER_BASE_URL=/todo npm run build.

@meltyshev commented on GitHub (Oct 5, 2020): Can you try to change the line in `client/src/history.js` from `export default createBrowserHistory();` to `export default createBrowserHistory({ pathname: '/todo' });`. Also, there could be some issues with socket connection, if that happens - try to change the line in `Dockerfile` from `RUN npm run build` to `RUN REACT_APP_SERVER_BASE_URL=/todo npm run build`.
Author
Owner

@newhinton commented on GitHub (Oct 8, 2020):

Thank you for your help, but sadly i couldn't get it to work, but it could very well be that i made a mistake with the proxy and your directions were perfectly fine.

However, for anyone that is interested in running planka behind a proxy on '/', this are the proxy settings you need:

        ProxyPass /socket.io ws://127.0.0.1:3000/socket.io/
        ProxyPassReverse /socket.io ws://127.0.0.1:3000/socket.io/

        ProxyPass / http://127.0.0.1:3000/
        ProxyPassReverse / http://127.1.0.1:3000/
        ProxyPreserveHost On
@newhinton commented on GitHub (Oct 8, 2020): Thank you for your help, but sadly i couldn't get it to work, but it could very well be that i made a mistake with the proxy and your directions were perfectly fine. However, for anyone that is interested in running planka behind a proxy on '/', this are the proxy settings you need: ``` ProxyPass /socket.io ws://127.0.0.1:3000/socket.io/ ProxyPassReverse /socket.io ws://127.0.0.1:3000/socket.io/ ProxyPass / http://127.0.0.1:3000/ ProxyPassReverse / http://127.1.0.1:3000/ ProxyPreserveHost On ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/planka#36