Hello, I am trying to run my Payload server through an Apache reverse proxy, but I am having trouble with the admin panel. My reverse proxy's location is set to
). Since serverURL (
) does not allow for paths, I ended up changing the webpack config.output.publicPath to
. With this,
works perfectly and the admin panel is accessible at
, but it hangs on the loading screen. It appears that when the admin panel tries to fetch users or any content from the API it fails because it tries
I tried changing routes.api to
, but now the actual API is located at
, and the admin panel tries to fetch using
(which now doesn't exist).
I know I could just make a new virtual host and essentially run the whole payload server on its own subdomain (e.g.
), but it is not ideal.
That being said, does anyone know of a good way to change the URL that the admin panel uses to contact the API (or maybe just a better way to go about this)? Thanks in advance!
I just found [this](https://nouance.io/articles/how-to-host-payloadcms-on-a-subdomain-and-subpath-with-nginx
) link from another thread about subdomains and subpaths for nginx. I'm going to revert the webpack config to default and will try changing routes.admin to
and routes.api to
and then create an Apache rewrite rule to remove /foo.
I have not been able to get any rewrite rules to work as of yet
Good morning @bonk! I've never done this on an apache setup, but are you currently stuck on implementing the rewrites specifically?
Thanks for the response! I was not able to make it work with the rewrites. I was looking at the apache docs in regards to the proxy flags as well, but I'm not that well versed in apache! This is the proxy section of the virtual host conf file:
ProxyRequests Off ProxyPreserveHost On ProxyVia Full <Proxy *> Require all granted </Proxy> <Location /foo> ProxyPass http://127.0.0.1:8081 ProxyPassReverse http://127.0.0.1:8081 </Location> RewriteEngine on RewriteRule ^foo/(.*)$ $1 [QSA,P]
I tried with and without /foo admin and api routes on the node side too
I actually think I figured it out. My proxy location was not correct. I didn't even need the rewrite rules. All I did was change the routes in the payload.config to /foo/api and /foo/admin adjusted my apache conf file to be this:
ProxyRequests Off ProxyPreserveHost On ProxyVia Full <Proxy *> Require all granted </Proxy> ProxyPass /foo/ http://127.0.0.1:8081/foo/ ProxyPassReverse /foo/ http://127.0.0.1:8081/foo/