Dockerized WHMCS w/ NGINX Reverse Proxy
Hello!
I have been thinking of dockerizing my WHMCS setup recently, so I grabbed a dev license and tried setting everything up. The frontend is loading fine, but I'm getting a too many redirects error when trying to access the admin panel. Here's the docker compose file
This is the location block that handles the proxying
location / { proxy_http_version 1.1; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Connection ""; proxy_pass http://whmcs-prod/; }
Any help would be appreciated
Comments
You should remove the trailing slash from the proxy pass directive and add the "host" header. Also, proxy redirect should be set to off and a few other minor things.
Try something like this:
Changed it to this, but no luck.
If it may be of interest, this is the cURL output:
The only workaround I've found till now was to set the WHMCS system URL to an http URL.
The first question that popped to mind was actually if whcms is configured to enforce HTTPS but I didn't ask that for no particular reason.
Since you're using http in your nginx config WHCMS will continously send your browser an http 302, which will change nothing since nginx will still perform a http request (nginx won't respond to the whcms request but rather relay it to your browser). Hence the permant redirect.
Since you're using a reverse proxy you're basically making two requests, one to nginx and then nginx makes one to whcms. The last request is perfectly fine to be http but then you'd probably run into other issues (since whcms thinks it runs on http it might not load images over https for example). The simplest solution would be to change the nginx config to connect over https, but adding something like
proxy_set_header X-Forwarded-Proto https;
might also work if that is supported by WHCMS.Sorry for the short replies, feel free to ask for more details. Just having a fight with my phones keyboard atm..
Thanks a ton, I'll give that a go after WHMCS reissues my Dev license.
No problem mate, I greatly appreciate your help. I was stuck on a dead end on this, you've helped me out a lot