PeytonSeabolt
Posts: 6
Joined: Thu Apr 30, 2015 2:36 pm

Apache Server public connection issue

Sun Apr 21, 2019 6:12 pm

So I have a Pi and I have an Apache server on it. I can access this pi fine on the local network, and I have forwarded port 80 to point at the Pi server on my router, and when I type my router's public IP I see the white page that says, "Index of" and shows the file structure of my server.
At the bottom it says Apache/2.4.25 (Raspbian) Server at xxx.xxx.xxx.xxx Port 80 so I know im accessing the server, and when I click the html folder it redirects me to the correct page and shows the Pi's ip on the local network in the address bar. The thing is, the page doesn't load and instead gives me an error that the site was taking too long to respond. Essentially, the public IP takes me to the right page but the page will not load for me. Anyone got any ideas? Sorry if I'm all over the place. This is part of my capstone project for school.
Attachments
fa74e639787f10c88d5596d5db9dccd2.png
fa74e639787f10c88d5596d5db9dccd2.png (17.1 KiB) Viewed 163 times

Ernst
Posts: 1144
Joined: Sat Feb 04, 2017 9:39 am
Location: Germany

Re: Apache Server public connection issue

Sun Apr 21, 2019 6:24 pm

PeytonSeabolt wrote:
Sun Apr 21, 2019 6:12 pm
So I have a Pi and I have an Apache server on it. I can access this pi fine on the local network, and I have forwarded port 80 to point at the Pi server on my router, and when I type my router's public IP I see the white page that says, "Index of" and shows the file structure of my server.
At the bottom it says Apache/2.4.25 (Raspbian) Server at xxx.xxx.xxx.xxx Port 80 so I know im accessing the server, and when I click the html folder it redirects me to the correct page and shows the Pi's ip on the local network in the address bar.
Do you spot the problem ? From the outside you will never be able to access the inside local network IP address.
Somewhere you must have specified something wrong in your html page(s).
The road to insanity is paved with static ip addresses

PeytonSeabolt
Posts: 6
Joined: Thu Apr 30, 2015 2:36 pm

Re: Apache Server public connection issue

Sun Apr 21, 2019 6:36 pm

Ernst wrote:
Sun Apr 21, 2019 6:24 pm
PeytonSeabolt wrote:
Sun Apr 21, 2019 6:12 pm
So I have a Pi and I have an Apache server on it. I can access this pi fine on the local network, and I have forwarded port 80 to point at the Pi server on my router, and when I type my router's public IP I see the white page that says, "Index of" and shows the file structure of my server.
At the bottom it says Apache/2.4.25 (Raspbian) Server at xxx.xxx.xxx.xxx Port 80 so I know im accessing the server, and when I click the html folder it redirects me to the correct page and shows the Pi's ip on the local network in the address bar.
Do you spot the problem ? From the outside you will never be able to access the inside local network IP address.
Somewhere you must have specified something wrong in your html page(s).
in my php when i use the Header meathod to redirect i use an IP address follwed by the file system. So I need to remove the ip address from that line? Here is an example: header("Location: http://192.168.0.11/html/Login.php"

Ernst
Posts: 1144
Joined: Sat Feb 04, 2017 9:39 am
Location: Germany

Re: Apache Server public connection issue

Sun Apr 21, 2019 6:52 pm

PeytonSeabolt wrote:
Sun Apr 21, 2019 6:36 pm
in my php when i use the Header meathod to redirect i use an IP address follwed by the file system. So I need to remove the ip address from that line? Here is an example: header("Location: http://192.168.0.11/html/Login.php"
Unfortunately I do not have sufficient knowledge on this and it has been many years since I worked with html.
But I did find something that may help you: https://www.php.net/manual/en/function.header.php
See the last note the page.
The road to insanity is paved with static ip addresses

User avatar
DaveyDave1999
Posts: 28
Joined: Tue Apr 16, 2019 9:16 pm
Location: United States, Hawaii

Re: Apache Server public connection issue

Sun Apr 21, 2019 11:29 pm

Code: Select all

header("location:Foldername/")
If you want a SEO friendly website tho, you should setup a redirect using .htaccess instead.
Blog about Raspberries coming soon...

User avatar
rpdom
Posts: 14483
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Apache Server public connection issue

Mon Apr 22, 2019 4:59 am

PeytonSeabolt wrote:
Sun Apr 21, 2019 6:36 pm
in my php when i use the Header meathod to redirect i use an IP address follwed by the file system. So I need to remove the ip address from that line? Here is an example: header("Location: http://192.168.0.11/html/Login.php"
Is 192.168.0.11 the same Pi, or is it another one on on your internal network?

If it is the same one, then use something like header("Location: http://" . $_SERVER['HTTP_HOST'] . "/html/login.php")
(There may be other, better ways to do it).

If not the same, perhaps you need to direct it to something similar and use Apache's reverse proxy module to redirect internally to the other server.

Return to “Troubleshooting”