Nginx – HTTP connections are fast from local network, very slow from the outside world

domain-name-systemhttpnginxraspbianufw

I setup a WordPress server in a Raspberry Pi with nginx, MariaDB and ufw. I also setup the No-IP service. When I access the server from my local network (192.168.0.173) I get a fast response but when I try to access from the outside world the response is very slow (aarroyoc.noip.me). It loads, as I can see the title bar in the browser but it just keeps loading and loading.

I think WordPress isn't the problem because when I access from local network the speed is fine. My router bandwith can't be a problem, I usually run game servers and I didn't experienced such problems.

I downloaded the frontpage using cURL and the response was fast, so the problem might be in the browser but I don't know what is making the web so slow.

Why do I get a fast response from local network browsers and cURL outside Internet but it's so slow on outside Internet browsers?

EDIT

Doing more tests I've found that PHPInfo is fast (http://aarroyoc.noip.me/phpinfo.php) from outside network but the WordPress panel is slow (http://aarroyoc.noip.me/wp-admin/) only from the outside.

Best Answer

That's because you set up your Wordpress server to redirect to your internal IP, 192.168.0.173. So when external clients try to reach your Wordpress server, they are being redirected to http://192.168.0.173/wp-login.php which will, of course, fail after a timeout. The same goes for your Wordpress homepage, there are a number of resources, like CSS and image files, that are being served from http://192.168.0.173 instead of http://aarroyoc.noip.me.

The reason why PHPInfo works, is because it's completely self-contained. Even the PHP logo is embedded into the HTML. Check the source to see what I mean.