Question

I get an odd 502 error on my hosted site.

Hi all- I’m getting a funny error. I have an index.php file as the default landing page for my badastronomy.com site, and it redirects to my blog on syfy.com. This is all it is:

<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: https://www.syfy.com/tags/bad-astronomy" );
?>

I was told this error started popping up around the new year (I rarely check the site, obviously). Has anyone seen anything like this before? What’s funny is that the index.html file on the site works (it’s a very old site, and I keep it around for historical purposes), so I know the server is working. Thanks!

Subscribe
Share

Oops. I didn’t say in the body of the question that it’s a 502 Bad Gateway error.


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

This comment has been deleted

Thanks for the info, ryanpq. I’m running Nginx but I’m not sure with what else. I’ve done some server maintenance before but it’s been a while, so I’m not familiar with this setup.

I don’t have a php-fpm file/dir in that location, either. I did a “find” and nothing with the name fhp turns up from my root dir.

As it is, I don’t want all queries to redirect, just ones to the main url. So if they just go to www.badastronomy.com it sends them to my blog, but if they add index.html to the URL they can see the badastronomy.com site. It’s a weird setup but I’m contractually obligated to do this. :/

A 502 error is returned when a web server cannot reach an upstream service needed to load the site. Based on this being a PHP site returning a 502 I would guess that you are running Nginx+PHP-FPM on your site rather than Apache with mod_php.

If that is the case then this would indicate that your php-fpm service either isn’t running or is returning an error. On Ubuntu you can find the logs for this process in /var/log/php-fpm

If this domain only redirects to your syfy.com blog and does not serve any other content you can simplify things. PHP would not even be necessary. You can create a 301 redirect directly in your nginx configuration /etc/nginx/sites-enabled/default by following this guide.