Access localhost from iPhone
I'm asking this here, because it does not appear to belong in the networking section. I am attempting to access the site I am creating from my iPhone. The site is on my Linux laptop, in /var/www/html/<subdirectory>/index.php
I have followed several online guides and Stack Overflow. When I type ifconfig, my inet address under wlp2s0 is 192.168.0.5 I have tried typing this address with and without http:// with a / on the end of the address, with the subdirectory containing my website on it, and Safari cannot connect to any of them. I am using Mint, so I opened the Firewall Configuration GUI program, and the firewall there is turned off. I have examined the logs for Apache2 and firewalld and there is no evidence of an attempt to access the computer. Both devices are on the same wireless network. What else can I try to access this? Thanks in advance. |
well, first of all, if this is from a laptop then your first check would be to make sure the site it working. opening a browser to from the laptop to http://localhost should open to the website otherwise you have a configuration issue there. my guess is you dont have it configured right so i would definitely start there.
if that is not the issue and the webpage opens fine then i would do is make sure you have the firewall down and selinux disabled. if by taking them down you get access then you know it is one of those two. oh, also in your website configuration file, set loglevel debut inside your site directive section with custom logs...that will give you a lot more info on what is going on. start with that and you should start down the right path. |
The site works without any problems on my laptop, the same machine the server is running from.
The firewall is turned off, at least in the GUI program Firewall Configuration, and I have disabled apparmor. I still cannot connect from my iPhone. I have added debug as the loglevel in apache2.conf, but /var/log/apache2/apache2.log still has no entries in it. Is there anything else I can try? |
okay, so if the site is being served to localhost then we know apache is configured correctly to serve and the build is not wrong. in the apache configuration file, did you allow access using like
Code:
<virtualhost *:80> plus, like i said before, you should add in your configuration file site directive to set... Code:
<virtualhost> |
I have debug loglevel. The error.log and access.log only contain references to visits from the laptop. I have also attempted visiting from my desktop with no success.
The directories /usr/share, /srv and /var/www all contain the following entries: Code:
Options Indexes FollowSymLinks Is it related to the firewall? As I mentioned, this appears to be turned off, but perhaps there is another setting on this laptop that is blocking traffic? |
okay, so you, a relative novice looking at the logs may say there is nothing is different than me a person with over 20 years of running an apache webserver. so if you refuse to put your logs on here, for whatever reason i dont know, if the website is being served locally and you have require all granted within the site configuration then the issue is almost certainly that the firewall OR selinux is blocking it.
now, while you are running mint, and i am not as familiar with mint, it does seem to be an offshoot of the debian/ubuntu tree so i would say this. first in a command window as su (or using sudo) do Code:
# ufw disable if that is it one of the two, then do Code:
# ufw enable |
here is a guide you can use to understand how to control the mint firewall since it is ufw...
managing ufw |
First of all, thank you very much for your help and your patience. The reason I didn't post the logs is that they appeared to be ordered by time of entry, and the latest entry was prior to the changes I made. I will post error.log here. I have included only results after I started the machine again at 10pm last night, as I cannot post a larger amount.
error.log: Code:
[Sun Feb 04 22:16:22.325207 2018] [mpm_prefork:notice] [pid 2060] AH00163: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations I have disabled firewall and apparmor. Mint does not have SELinux installed. This has not made a difference. I also saw that in my Mint configuration file there is a line, Code:
Mutex file:${APACHE_LOCK_DIR} Code:
DefaultRuntimeDir ${APACHE_RUN_DIR} Please let me know if you need any more information. |
okay, so what is the configuration of your network. this laptop, is it behind a router...? how are you getting the internet to the laptop and how is the internet getting to your phone and how is your phone getting to the laptop?
so, do you have a server that masquarades the network to a sub network or do you have a wifi router and both are connected via wifi to each other or the laptop is connected to the wifi and the phone is not? the default runtime directory is the directory apache is configured to run out of. if that was messed up then it would not run properly at all and the lock dir probably is just for dav operations which would not effect here. |
I have actually just left the house. I am going away for a week. I will connect the laptop and phone to wifi this afternoon and test again. Before I left, both the laptop and phone were connected to the same wifi network, broadcast from a router. The desktop is also on the same network, but it is connected via Ethernet. Is that the difference? Could it be settings on the router?
Regarding the conf file, should I comment out the Mutex line and include the DefaultRuntimeDir line so that it matches the desktop settings? Thanks |
if you can reach the website via localhost the issue is NOT the apache configuration. if apache is putting up a website and from your logs, was working well...it is doing its job. if there is a failure then it is the phone's communication to the laptop. so, if you have them BOTH VIA WIFI (this is a must), then you get the laptops ip address and type into the browswer of the phone...
Code:
http://ipaddress.of.phone ...but they HAVE TO BE on the same network. if you were using your phones carrier signal rather than the wifi, it would not work because the router's firewall would likely block you accessing the website from the laptop. in order for you to communicate that way you would have to forward a port from the router to the laptop which i will not go into. there also would be no domain name here for the same reason, it is communication via ip address on the same subnet. |
Both the laptop and the phone are on the same wifi network. Apparmor is stopped. I have typed ufw disable. I searched http://192.168.15.113 in the search bar from Safari on my phone, which is the IP address right now for wlp2s0 when I run ifconfig, and Safari cannot connect. This is on a different wifi network to the one I used this morning, so it is not related to the network I run at home either.
To recap: Both devices are on the same network; No firewall is enabled; I can access pages on my laptop, even using the external IP address mentioned above, not just 127.0.0.1; Safari cannot connect to the laptop. If there is anything else I can try, let me know, otherwise I may have to simply develop for mobile on the desktop, which can connect, but it would be great if I can fix this issue. I am out of ideas. Thanks for all your help once again. |
By the way, I have just checked, and an Android phone is also unable to connect, so it should not be an issue with my iPhone. I also tested this with another laptop on the same network, and it was also unable to connect.
I have also attempted connecting the laptop via ethernet to the same network, and it did not work then either. This would seem to suggest that the problem is with this laptop, however the firewall is down, SELinux is not installed, and apparmor is off, so I'm really not sure what else the problem might be. |
okay, so it is this simple, something is interrupting communication between the phone and the laptop. it is clearly on the laptop side. the tools you are going to need are all available but you are going to have to figure this out.
i would start by getting a command line program for your phone or using another computer and ping the other laptop. if the pings are accepted then basic icmp communication exists buy my guess is it will not. if it does not, it is 100% ONLY a firewall blocking you. if it does go through then you need a port scanner. you are going to use that to scan the ports of the laptop. it will tell you which ones are open. my guess is none will be. for a http server, you need port 80 open. if none are open, it is 100% a firewall blocking you. then you need to go through your logs and see if that will tell you the program name or what. i would start with /var/log/messages. that is the default log for dumping location for firewalls. go to your phone and put in the address and try and hit your laptop like 10 times in a row then go to the logs and you should be looking for a group of lines now which is easier to spot that show the hit but it was dropped. |
Thanks for that advice. I will need my desktop to do that, so I will have to wait till next week, but that sounds promising.
I will make an update here when I have tried those steps. |
I have just tried pinging my laptop from the desktop, and it worked. I got 0% packet loss. However the browser on my desktop is unable to visit the server on my laptop. When I enter the laptop's IP address in the URL bar, it is unable to connect.
I ran nmap and it stated that port 80 is open for http. I do not have a file or directory in /var/log called messages. I have checked the other log files and haven't found any evidence of the pings. This is the result of Code:
ls /var/log Code:
alternatives.log apport.log.3.gz auth.log.1 cups fsck kern.log.2.gz ntpstats syslog.1 tallylog I did find the following entry in syslog after disabling apparmor: Code:
Feb 12 11:14:12 dylanuszwei-Satellite-P750 systemd[1]: Stopping LSB: AppArmor initialization... Let me know if you need me to post any more information up here. |
okay, so that could be significant but i dont know enough about apparmor and the logs to say for certain.
first on the laptop run... Code:
netstat -tulpn also, i dont know what apparmor does specifically but if that might be the issue then you should use this guide to stop apparmor and make sure it does not start... stopping apparmor specifically... this one stops it as a current running process Code:
sudo /etc/init.d/apparmor stop Code:
sudo update-rc.d -f apparmor remove |
I ran netstat -tulpn as root and these are the results. I only see one entry for apache. Is it running on IPv6?
Code:
Active Internet connections (only servers) |
okay, something is going on here and i have no idea what specifically. i can see from the netstat output that apache is listening. from your log it told me you have it set to require all granted and you can reach it from localhost. so apache is nearly for certain not the issue. there is NO WAY the issue is on the side of the phone because that is the simple part but if when you set it on LOGLEVEL=debug and you dont see a reference to the phones request in the log then there is something clearly intercepting the request from the phone on the laptop.
i dont know if you know this but you have to use BOTH commands. one command only stopd apparmor temporarily but you want it stopped and disabled. 1. you need to stop it, 2. disable it from starting on boot, 3. restart your computer 4. check your bootlog to make sure it did not start look in your boot log and see if there is a reference to apparmor or something in there. also check your sys log to see if there is any reference in there. by everything i see it should work so i dont know. i would specifically go to a mint forum (i think there is a mint forum on linuxquestions) and ask someone there because maybe there is something specific to mint that is blocking it... |
I've disabled apparmor to prevent it from starting at boot. I rebooted and confirmed that apparmor did not turn back on again, but that did not resolve the issue.
I've posted this on the Mint forum now. I will let you know if I get an answer. Thanks for all your help. |
Just an update for anyone looking at this post. I have now successfully accessed a localhost on a Mac on the same network from my phone, so the router settings are not the issue, which I thought they might be for a while.
I have posted this question on the Mint forum and on superuser.com, but I have not received a response yet. If anyone does know of a solution, I would be very eager to hear it, but for now it looks like I can't use this laptop for mobile testing. |
All times are GMT -5. The time now is 11:24 PM. |