Self-hosting WordPress site behind NAT results in private IP being shown in client

1

I'm experimenting with self hosting a WordPress site on a Raspberry Pi. I've got port forwarding set on my router (public IP 1.2.3.4) to forward port 10080 to my Raspberry Pi's private IP (192.168.2.2) port 80. But when I try to connect to it from the public Internet (e.g. http://1.2.3.4:10080), the client "receives" the private IP from the server and tries to continue with that. I.e. I enter http://1.2.3.4:7777 in a client connected to the public internet. It tries to connect for a while, then when it times out, I see in the client's address bar the following: http://192.168.2.2/wp-login.php?redirect_to=http%3A%2F%2F1.2.3.4%3A10080%2F. Why is "192.168.2.2" seen at all in the client? Is there something I need to adjust?

Thanks!

Rusty Lemur

Posted 2017-04-04T18:19:32.480

Reputation: 513

If I recall correctly, you have to point the WordPress URL to the public IP address from within the site admin functions or else WordPress does redirection somehow.... I posted a similar question here: http://wordpress.stackexchange.com/questions/256495/any-specific-reason-why-images-do-not-show-on-site but it was just the admin configs that needed changed...

– Pimp Juice IT – 2017-04-04T18:24:40.203

If I recall correctly though, I had to change the WordPress Address URL to http://www.<domainname.com>\WordPress and changed the Site Address URL to http://www.<domainname.com>, made "public" DNS changes, waited for that to propagate out, and then I was able to get it to work as expected. You may need to plug in the private IP address and port number in your case if you don't have DNS. I used standard ports so I didn't mess with any port numbers to easy enough to test though I suppose – Pimp Juice IT – 2017-04-04T18:28:29.543

Thanks for the comments. I think they are close to getting me what I need, but I'm not sure what the difference between "WordPress Address" and "Site Address" is. Should they both/either be set to http://1.2.3.4:10080? When I tried that, it didn't work, so I'm wondering if one or the other should have port 10080 omitted. I'm not using public DNS, just an IP address for the time being.

– Rusty Lemur – 2017-04-05T00:41:11.430

Rusty - I would suggest this to start unless you already have and waited long enough. Configure it how you think it should be that makes the most sense to you so if it's <ip address>:<port> then configure it that way. Then wait for a while up to a few hours to see if it start working. I recall changes taking quite a while in my case. If it's not too critical, get it set at the end of a day, and then check it at the beginning of the next day. – Pimp Juice IT – 2017-04-05T03:01:02.413

No answers