0

I've set up a webserver (Apache2) on my Raspberry Pi 3. The latest versions of PHP, MariaDB and Wordpress are running on it.

I can access the site on my LAN on different devices, however, I do not reach it when connecting to it via the internet.

I know my public IP and the IP of the PI, I've set up port-forwarding and I can see on my Raspberry Pi's access log that e. g. my mobile phone tried to establish a connection.

I was able to see the default Apache-webpage when I connected to my webserver via internet but since Wordpress is running it throws a time-out-error when accessing through the internet. In the log HTTP status code 301 appears.

My router and the PI are listening on Port 80. I used the Open Port Check Tool to find out if it can see my service; it does.

Do you have any idea to solve my problem?

* EDIT 02 / 13 / 2018 *

The result of Curl -I XXX.XXX.XXX.XXX is the following:

HTTP/1.1 301 Moved Permanently

Date: Tue, 13 Feb 2018 18:14:03 GMT

Server: Apache/2.4.25 (Raspbian)

Location: http://192.168.XXX.XXX/

Content-Type: text/html; charset=UTF-8

closed as off-topic by Nathan Johnson, EAMann Feb 15 '18 at 23:40

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions that are too localized (such as syntax errors, code with restricted access, hacked sites, hosting or support issues) are not in scope. See how do I ask a good question?" – Nathan Johnson, EAMann
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Please run curl -i XXX.XX.XX.XXX on your public IP from outside and add its output to the question. – sandrodz Feb 13 '18 at 14:49
1

WordPress keeps WP_HOME and WP_SITEURL in DB, this is set during initial installation and usually is the domain of your website, in your case it is a LAN IP.

Your visiting site via WAN IP, but WordPress redirects to LAN IP, causing redirect loop which obviously fails.

To fix this, change WP_HOME and WP_SITEURL values in DB.

Or simply add this to wp-config.php:

define('WP_HOME','http://wanip');
define('WP_SITEURL','http://wanip');

You can confirm this theory buy running curl from WAN, it will show exactly what redirection is happening.

curl -I XXX.XX.XX.XXX

Also remember that browsers cache redirection, so once fixed, clear the cache and check again, or use curl.

  • Unfortunately your soultion didn't work out. See my edits. – Linus Feb 13 '18 at 18:37
  • @Linus 192.* is your lan IP right? So my theory of redirection is correct. Check in DB if WP_HOME and WP_SITEURL values where actually set as WAN IP. – sandrodz Feb 13 '18 at 20:15
0

There are many different factors involved in this situation.

Given your curl output my next guess would be that your router has NAT functionality. https://en.wikipedia.org/wiki/Network_address_translation If so, try to provide direct access to your server by allowing port 80 in your router and setting the destination IP address to your Pi.

For the next steps you can temporarily move your wordpress into a subdirectory:

cd ..
mkdir wordpress_temp
mv www/*(D) wordpress_tmp/

I've been hosting from home myself and would suggest that as next step you try to access a simple HTML page. Just place an index.html file into your /var/www/ directory. Then try to access it from outside directly:

http://yourdynamicdomain.net/index.html 

If that works out, go one step further and just make a dummy php file. Call it index.php, content:

<?php phpinfo(); ?>

Please update your post with the results, then I may be able to assist further.

  • The results of this test will show if the culprit here is a.) Wordpress or b.) your server configuration. – Lee.D Feb 13 '18 at 19:30
0

The following steps solved my problem:

  1. Reinstalling the LAMP-webserver and WordPress
  2. Activating port-forwarding to the Pi's local IP
  3. Typing in the public IP into the URL bar
  4. Continuing the installation

Now I am able to type in the public IP and I will be redirected to the IP without any problems. A dynamic domain works fine, too.

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