0

I'm trying to set up a simple web server with my Pi. I have a WordPress installation on Apache and it works well. (I can see the website when I access the Pi's LAN IP on my home network).

I set my router, (Vigin Media Hub 2), to assign a specific IP. (Say 192.168.0.20) to the Pi based on it's MAC address and set up port forwarding to the port that goes to 192.168.0.20.

Here is the odd thing: if I try to connect to the server from an outside network, the external IP will resolve to the local IP (192.168.0.20) of the Pi. So, of course, it can't connect since 192.168.0.20 isn't a WAN IP.

Can anyone advise me on what could be going wrong?

1
  • When you try to connect to your home IP address, what do you get back?
    – Jacobm001
    Commented May 31, 2017 at 17:50

1 Answer 1

1

My guess is that either Apache or WordPress is sending a 302 redirect after the first connect. Something like this:

  • you connect to mydomain.foo:80
  • you send GET / HTTP/1.0
  • you send Host: mydomain.foo
  • either Apache or WordPress says "nope, but I can send you to the real website, which is http://youripaddress" on an HTTP 302

You can verify this by using a developer tool like here in Chrome or here in Firefox and load the page. If I'm right, you should see the first connection come in and then the redirect sent.

If I'm right, you can fix this probably at the WordPress level. See this question:

Log in to your WordPress admin panel, go to Settings > General in the menu.

Check that the fields for both 'WordPress Address (URL)' and 'Site Address (URL)' have the correct site address that you want to use.

If not, check the Apache level, particularly ServerName and ServerAlias in the Apache config. It would help to get used to generating requests manually for troubleshooting.

3
  • Most likely this. WordPress is a pain when I comes to domains and will, by default, redirect you to whatever domain (or IP) you initially set it up with during the installer
    – mrwhale
    Commented May 28, 2017 at 8:07
  • Thank you @BJ Black! You are a beautiful and amazing person, that was exactly the problem =D Edit for further clarity: it was the WordPress giving the problem, not Apache.
    – Pedro
    Commented May 28, 2017 at 21:42
  • Much more praise than I deserve @Pedro. Thank you. Happy hacking!
    – BJ Black
    Commented May 28, 2017 at 23:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.