What errors or information do you see in the console?
Infinite redirect loop
Hello at all,
I’m trying to install Ghost for the past 6 hours but I’m in a lot of troubles. I want to use Nginx as reverse proxy. I configured Nginx to use 443 and to proxy pass to Ghost. Now starts the pain :
on Firefox, I have an infinite 301 redirect loop. On certain pages, not all of them. Mostly on the homepage.
I then realized that Chrome was working fine for some time. Until it failed the same way
I have tried to clear cache, history, restart browser. The results are not consistent at all.
So now I’m ending up at testing with wget --no-cache.
But now, everything is working except the homepage and I really don’t know why…
I don’t need SSL between nginx and ghost so I did not “ghost setup ssl”. I already have a valid certificate for nginx.
I must say that I have quite a lot of experience on Nginx and that I have been working with proxy pass many times. I have never got this result. I wonder who is doing the double redirection that fails on the homepage.
I am just getting crazy, any help would be appreciated
thanks a lot
I have never worked on Express. But I noticed that on Ghost, paths must be terminated with /.
For example /ghost : if the final / is not there, there will be a 301 redirect to /ghost/
I have compared with another setup I did with Nginx + SSL + Proxy pass and there is not the same behavior.
Here are some troubleshooting steps that might steer you in the right direction:
If you’re using https, your Ghost URL must be set to https://.... If you make a change, make sure you restart ghost!
Ensure you’re passing the X-Forwarded-Proto header from nginx to ghost
If you have CloudFlare in front of your site, make sure you have SSL set to strict or full - setting it to flexible will cause issues with a site upgrading HTTP requests
I have done A LOT of testing of different settings. To answer your points :
1/ My ghost url starts with https://
2/ I’m passing the right headers. I have check the ghost-cli Nginx template
3/ I’m not using Cloudflare.
I found a temporary solution : when editing the content/settings/routes.yaml file and changing the default / route to /home/, everything works now. So the problem is really with the homepage. But this fix is not enough as the / URL is still broken
For some reason, it works fine when I enable the proxy cache. But I can’t enable it for all page (because of the ghost BO). So disabling the cache for /ghost/ leads to a infinite loop.
With your caching strategy, that’s really weird, the rule of thumb is the admin panel should never be cached (e.g. /ghost/*) since most 1-click caching solutions don’t work well with them.
Can you try using curl locally to see how ghost is behaving?
e.g. curl -I http://127.0.0.1:2368/ghost/ -H "Host: mydomain.com" -H "X-Forwarded-Proto: https"
If that’s working, then you know that everything in Ghost is set up properly so you can move to debugging nginx
Actually, my blog is working fine on Chrome now, all pages fine.
But not on Firefox. Many page are still redirecting. It really weird. I tried in private mode, I tried from safe mode, I tried to clear the cache…
For information, this is SOLVED. I was using aaPanel with Nginx module. It seems aaPanel doesn’t do it right despite my numerous tries to change the nginx config.
I removed aaPanel, reinstalled Nginx manually and reinstalled the blog. Working now. Thanks for your help.