AnswerBun.com

How to Access Apache Virtual Host from Cell Phone?

Server Fault Asked on January 1, 2022

I’m developing a mobile web application using Django. Currently I can start the Django development server like this:

python ./manage.py runserver <my-ip>:8000

When I do that, I’ll get a popup window on my Mac that says,

Do you want the application "python" to accept incoming network connections?

If I click the Allow button and then enter the URI “:8000” I can access the website from my cell phone.

However, their are times that I’d like view plain HTML pages on my phone as well. To that end, I’ve created an Apache virtual host call “localdev” that is mapped to my /www directory:

# /etc/apache2/httpd.conf
...
DocumentRoot "/www"
...
<Directory "/www">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
...
Include /private/etc/apache2/extra/httpd-vhosts.conf

# /etc/apache2/extra/httpd-vhosts.conf
NameVirtualHost *:80
<VirtualHost *:80>
    DocumentRoot "/www"
    ServerName localdev
    ErrorLog "/private/var/log/apache2/localdev_error_log"
    CustomLog "/private/var/log/apache2/localdev_access_log" common
    <Directory "/www"> 
        DirectoryIndex index.html 
    </Directory>
</VirtualHost>

If I have a website in /www/mysite, I can access it on my Mac using this URI:

http://localdev/mysite/index.html

However, if I try to access that virtualhost site on my phone with this URI:

<my-ip>/mysite/index.html

… I get this message:

Forbidden
You don't have permission to access /mysite/index.html on this server

I have two questions, the first one being more important:

  1. How can I access this site from my phone? This appears to be a pretty common Apache error message that can be caused by any number of things. I’ve read many articles about it but haven’t been able to resolve the problem. What am I doing wrong? Since I can access the site via my computer browser but not from my phone, I’m thinking perhaps it’s an OS X firewall issue.

  2. Is there some way I can configure my OS X (Mavericks) firewall so that when I start the Django development webserver, my computer will automatically allow incoming connections and I won’t get the pop-up window I described above? I’ve gone into System Preferences > Security & Privacy > Firewall Options and selected “Allow incoming connections” from the three “python” connections that are shown but I’m still getting the popup window.

One Answer

Are you actually including the file you have your virtual hosts defined in? From your question:

Include /private/etc/apache2/extra/httpd-vhosts.conf

vs

# /etc/apaches/extra/httpd-vhosts.conf

The file paths are different, making it appear you're not actually including the file you have your virtual host definitions in.

Answered by Christopher Karel on January 1, 2022

Add your own answers!

Related Questions

NGINX/GemInABox – static links aren’t properly passed

0  Asked on December 8, 2020 by anotherclueless

     

How do I start & stop my AKS cluster?

2  Asked on December 8, 2020 by sarabpreet-singh

   

Nginx rewrite: replace – with /

2  Asked on December 7, 2020 by tomas-morgan

   

SCCM Application Deployment – No Status or Errors

1  Asked on December 6, 2020 by jshizzle

 

Centos 7 Sofia-sip dependency for Janus sip gateway

2  Asked on December 6, 2020 by dmitriy-povolotskiy

   

Switching NICs in VPN tunnel

0  Asked on December 6, 2020 by kubek

   

Asterisk / Elastix Address Book and Call Recording

1  Asked on December 3, 2020 by ullash

   

How to know if mysql server is using sha_256 or caching_sha_256?

0  Asked on December 2, 2020 by noah-j-standerson

   

Booting a squashed filesystem from ISO

0  Asked on December 2, 2020 by rudolfs-bundulis

       

Ask a Question

Get help from others!

© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir